July 23, 2016
On Saturday, 23 July 2016 at 15:45:13 UTC, Andrew wrote:

>
> I've also tried adding the lines
>
> #ifndef MAP_FILE
> # define MAP_FILE 0
> #endif
>
> straight after the #include <sys/mman.h> line (reverting the previous change) and that compiles fine too.
>

Sorry, I meant after the #include <sys/mman.h> paragraph (outside the if clause)
July 23, 2016
On Saturday, 23 July 2016 at 15:45:13 UTC, Andrew wrote:
> On Saturday, 23 July 2016 at 15:06:12 UTC, Johan Engelen wrote:
>>
>> Where is MAP_SHARED defined?
>>
>> This is a bug in LLVM's compile-rt project, and it'd be good to find a proper fix for it.
>> Perhaps it is adding the correct header file, or adding
>> #ifndef MAP_FILE
>> # define MAP_FILE 0
>> #endif
>
> MAP_SHARED is defined in /usr/include/bits/mman.h as well:
>
> #define MAP_SHARED	0x01		/* Share changes.  */
>
> and /usr/include/sys/mman.h has the line:
>
> #include <bits/mman.h>
>
> I tried the following code, cut and pasting the header lines from GCDAProfiling.c:
>
> #include <errno.h>
> #include <fcntl.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
>
> #if defined(_WIN32)
> #include "WindowsMMap.h"
> #else
> #include <sys/mman.h>
> #include <sys/file.h>
> #endif
>
> int main()
> {
>   printf("%d,%d\n", MAP_FILE, MAP_SHARED);
>   return 0;
> }
>
> and it outputted 0,1

Huh?
Perhaps a different compiler is used when building ldc-profile-rt ?
Can you have a look at the commandline to build GCDAProfiling.c?
July 23, 2016
On Saturday, 23 July 2016 at 15:57:01 UTC, Johan Engelen wrote:

>
> Huh?
> Perhaps a different compiler is used when building ldc-profile-rt ?
> Can you have a look at the commandline to build GCDAProfiling.c?

Sorry, not sure if I completely understand you. cmake says:

-- The C compiler identification is GNU 4.9.1
-- The CXX compiler identification is GNU 4.9.1
-- Check for working C compiler: /software/bin/cc
-- Check for working C compiler: /software/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /software/bin/c++
-- Check for working CXX compiler: /software/bin/c++ -- works

/software/bin/cc -c runtime/profile-rt/profile-rt-38/GCDAProfiling.c -o a.o

compiles ok

/software/bin/c++ -c runtime/profile-rt/profile-rt-38/GCDAProfiling.c -o a.o

has errors to do with conversion from void pointers but nothing else.

If I grep within the build folder for GCDAProfiling.c I get the following lines in build.make:

runtime/CMakeFiles/ldc-profile-rt.dir/profile-rt/profile-rt-38/GCDAProfiling.c.o: runtime/CMakeFiles/ldc-profile-rt.dir/flags.make
runtime/CMakeFiles/ldc-profile-rt.dir/profile-rt/profile-rt-38/GCDAProfiling.c.o: ../runtime/profile-rt/profile-rt-38/GCDAProfiling.c
	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object runtime/CMakeFiles/ldc-profile-rt.dir/profile-rt/profile-rt-38/GCDAProfiling.c.o"
	cd /home/abrown/software/ldc/build/runtime && /software/bin/cc  $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/ldc-profile-rt.dir/profile-rt/profile-rt-38/GCDAProfiling.c.o   -c /home/abrown/software/ldc/runtime/profile-rt/profile-rt-38/GCDAProfiling.c
runtime/CMakeFiles/ldc-profile-rt.dir/profile-rt/profile-rt-38/GCDAProfiling.c.i: cmake_force
	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/ldc-profile-rt.dir/profile-rt/profile-rt-38/GCDAProfiling.c.i"
	cd /home/abrown/software/ldc/build/runtime && /software/bin/cc  $(C_DEFINES) $(C_FLAGS) -E /home/abrown/software/ldc/runtime/profile-rt/profile-rt-38/GCDAProfiling.c > CMakeFiles/ldc-profile-rt.dir/profile-rt/profile-rt-38/GCDAProfiling.c.i
runtime/CMakeFiles/ldc-profile-rt.dir/profile-rt/profile-rt-38/GCDAProfiling.c.s: cmake_force
	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/ldc-profile-rt.dir/profile-rt/profile-rt-38/GCDAProfiling.c.s"
	cd /home/abrown/software/ldc/build/runtime && /software/bin/cc  $(C_DEFINES) $(C_FLAGS) -S /home/abrown/software/ldc/runtime/profile-rt/profile-rt-38/GCDAProfiling.c -o CMakeFiles/ldc-profile-rt.dir/profile-rt/profile-rt-38/GCDAProfiling.c.s
runtime/CMakeFiles/ldc-profile-rt.dir/profile-rt/profile-rt-38/GCDAProfiling.c.o.requires:
.PHONY : runtime/CMakeFiles/ldc-profile-rt.dir/profile-rt/profile-rt-38/GCDAProfiling.c.o.requires
runtime/CMakeFiles/ldc-profile-rt.dir/profile-rt/profile-rt-38/GCDAProfiling.c.o.provides: runtime/CMakeFiles/ldc-profile-rt.dir/profile-rt/profile-rt-38/GCDAProfiling.c.o.requires
	$(MAKE) -f runtime/CMakeFiles/ldc-profile-rt.dir/build.make runtime/CMakeFiles/ldc-profile-rt.dir/profile-rt/profile-rt-38/GCDAProfiling.c.o.provides.build
.PHONY : runtime/CMakeFiles/ldc-profile-rt.dir/profile-rt/profile-rt-38/GCDAProfiling.c.o.provides
runtime/CMakeFiles/ldc-profile-rt.dir/profile-rt/profile-rt-38/GCDAProfiling.c.o.provides.build: runtime/CMakeFiles/ldc-profile-rt.dir/profile-rt/profile-rt-38/GCDAProfiling.c.o
"CMakeFiles/ldc-profile-rt.dir/profile-rt/profile-rt-38/GCDAProfiling.c.o" \
lib/libldc-profile-rt.a: runtime/CMakeFiles/ldc-profile-rt.dir/profile-rt/profile-rt-38/GCDAProfiling.c.o
runtime/CMakeFiles/ldc-profile-rt.dir/requires: runtime/CMakeFiles/ldc-profile-rt.dir/profile-rt/profile-rt-38/GCDAProfiling.c.o.requires

July 24, 2016
On Saturday, 23 July 2016 at 16:21:56 UTC, Andrew wrote:
> On Saturday, 23 July 2016 at 15:57:01 UTC, Johan Engelen wrote:
>
>>
>> Huh?
>> Perhaps a different compiler is used when building ldc-profile-rt ?
>> Can you have a look at the commandline to build GCDAProfiling.c?
>
> Sorry, not sure if I completely understand you. cmake says:

`make VERBOSE=1`, `make -n` or `ninja -v` print out the commands used to build the files (so you can also see which compile flags are used)

>
> -- The C compiler identification is GNU 4.9.1
> -- The CXX compiler identification is GNU 4.9.1
> -- Check for working C compiler: /software/bin/cc
> -- Check for working C compiler: /software/bin/cc -- works
> -- Detecting C compiler ABI info
> -- Detecting C compiler ABI info - done
> -- Check for working CXX compiler: /software/bin/c++
> -- Check for working CXX compiler: /software/bin/c++ -- works
>
> /software/bin/cc -c runtime/profile-rt/profile-rt-38/GCDAProfiling.c -o a.o
>
> compiles ok

Just to be sure: you are testing without any changes right (so with MAP_FILE in the source) ?



July 24, 2016
On Sunday, 24 July 2016 at 08:42:57 UTC, Johan Engelen wrote:
> On Saturday, 23 July 2016 at 16:21:56 UTC, Andrew wrote:
>> On Saturday, 23 July 2016 at 15:57:01 UTC, Johan Engelen wrote:
>>
>>>
>>> Huh?
>>> Perhaps a different compiler is used when building ldc-profile-rt ?
>>> Can you have a look at the commandline to build GCDAProfiling.c?
>>
>> Sorry, not sure if I completely understand you. cmake says:
>
> `make VERBOSE=1`, `make -n` or `ninja -v` print out the commands used to build the files (so you can also see which compile flags are used)
>
>>
>> -- The C compiler identification is GNU 4.9.1
>> -- The CXX compiler identification is GNU 4.9.1
>> -- Check for working C compiler: /software/bin/cc
>> -- Check for working C compiler: /software/bin/cc -- works
>> -- Detecting C compiler ABI info
>> -- Detecting C compiler ABI info - done
>> -- Check for working CXX compiler: /software/bin/c++
>> -- Check for working CXX compiler: /software/bin/c++ -- works
>>
>> /software/bin/cc -c runtime/profile-rt/profile-rt-38/GCDAProfiling.c -o a.o
>>
>> compiles ok
>
> Just to be sure: you are testing without any changes right (so with MAP_FILE in the source) ?

Thanks, I never knew about that flag. I am using the default file. The line that fails is this one:

/software/bin/cc  -DLDC_WITH_PGO -std=c11  -I/home/abrown/software/ldc/. -I/home/abrown/software/ldc/ddmd -I/home/abrown/software/ldc/ddmd/root -I/home/abrown/software/ldc/build/ddmd -I/home/abrown/software/ldc -isystem /Home/abrown/software/llvm/include -isystem /home/abrown/software/libs/include     -fPIC -O3 -DCOMPILER_RT_HAS_ATOMICS=1 -DCOMPILER_RT_HAS_FCNTL_LCK=1 -o CMakeFiles/ldc-profile-rt.dir/profile-rt/profile-rt-38/GCDAProfiling.c.o   -c /home/abrown/software/ldc/runtime/profile-rt/profile-rt-38/GCDAProfiling.c

It fails when I call it myself, but succeeds if I drop the -std=c11 flag. This I find very puzzling, since I've set in my environment variables that CFLAGS='-std=c11' so shouldn't the flag also be set when I just call the compiler without options?

Thanks again for all the help.

Andrew
July 24, 2016
On Sunday, 24 July 2016 at 11:32:56 UTC, Andrew wrote:
> /software/bin/cc  -DLDC_WITH_PGO -std=c11  -I/home/abrown/software/ldc/. -I/home/abrown/software/ldc/ddmd -I/home/abrown/software/ldc/ddmd/root -I/home/abrown/software/ldc/build/ddmd -I/home/abrown/software/ldc -isystem /Home/abrown/software/llvm/include -isystem /home/abrown/software/libs/include     -fPIC -O3 -DCOMPILER_RT_HAS_ATOMICS=1 -DCOMPILER_RT_HAS_FCNTL_LCK=1 -o CMakeFiles/ldc-profile-rt.dir/profile-rt/profile-rt-38/GCDAProfiling.c.o   -c /home/abrown/software/ldc/runtime/profile-rt/profile-rt-38/GCDAProfiling.c
>
> It fails when I call it myself, but succeeds if I drop the -std=c11 flag. This I find very puzzling, since I've set in my environment variables that CFLAGS='-std=c11' so shouldn't the flag also be set when I just call the compiler without options?
>
> Thanks again for all the help.
>
> Andrew

So this was definitely the problem, all I need to do is unset CFLAGS before I run make and everything works fine.

Thanks very much, for all your help and your patience with me.

Andrew
July 24, 2016
On Sunday, 24 July 2016 at 12:58:00 UTC, Andrew wrote:
>
> So this was definitely the problem, all I need to do is unset CFLAGS before I run make and everything works fine.
>
> Thanks very much, for all your help and your patience with me.

I'll still submit a patch to the LLVM guys working on compiler-rt. I think it is a latent bug because MAP_FILE is not strictly needed in the header file IIUC.

Great that it works for you now.

cheers,
  Johan

July 26, 2016
On Sunday, 24 July 2016 at 13:54:07 UTC, Johan Engelen wrote:
>
> I'll still submit a patch to the LLVM guys working on compiler-rt. I think it is a latent bug because MAP_FILE is not strictly needed in the header file IIUC.

http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/GCDAProfiling.c?view=diff&r1=276707&r2=276708&pathrev=276708
1 2
Next ›   Last »