-
Notifications
You must be signed in to change notification settings - Fork 407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
7.2alpha6 fails to compile with clang #14
Comments
Note that Apple clang 3.0 (211) from Xcode 4.2 compiles this, but the clang shipping with Xcode 4.3 does not. |
The code is checking that pointer comparisons behave like unsigned comparisons. It's purely a sanity check to preclude some subtle runtime bugs. The fact that it fails does not guarantee that the compiler is broken. In fact, in the version that I looked at, some platforms are exempted from this test. I don't remember doing that, which may mean that I forgot, or that someone else (Ivan Maidanski?) added the code. I would guess that this is unintentional clang behavior. It's testing the behavior of nonportable code, so it may not really be a bug, but it seems weird. (If the compiler defines the GNUC macro, it arguably is a bug, since gcc doesn't behave this way.) My guess is that it will cause the collector to break only if the OS allows memory mappings that cross the middle of the address space, i.e. the point at which pointer values "change sign", and only if runtime tests have the same issue. I would guess that 32-bit Linux allows this, so if the same clang front end is supposed to work there, it may be an issue. My strategy would be:
Hans
|
Hi Adrian, 28 02 2012, 00:30 Adrian Petrescu reply@reply.github.com:
This macro is intended to check whether compiler treats pointer comparison as unsigned integer comparison or not. It seems that used version of clang is broken regarding this issue (we can add a workaround (like we've done for ancient Borland compiler) in the hope that the produced executable won't be used in environments with both halves of 4 GiB space. The alternative, better, solution is to cast pointers to word whenever compared (requires a lot of work). BTW. What's the version of that 'default' clang? I tried: It works ok except for test_stack - something wrong with the atomic intrinsics. Regards.
|
Hi ivmai, For me it also fails with clang: $ clang --version Cheers, |
On 29 Feb 2012, at 00:05, Boehm, Hans wrote:
I get that error (see below) when compiling bdwg from repository with clang (see below) in 64-bit mode, but not in 32-bit mode. It compiles using llvm-gcc (see below) in 64-bitmode. When running clang on this program: Hans It is the clang one gets from latest Xvcode 4.3 developer package on OS X 10.7.3: LLVM-GCC: Makefile error: libtool: compile: clang -DHAVE_CONFIG_H -I./include -I../bdwgc/include -I./libatomic_ops/src -I../bdwgc/libatomic_ops/src -fexceptions -Wall -Wextra -g -O2 -fno-strict-aliasing -MT misc.lo -MD -MP -MF .deps/misc.Tpo -c ../bdwgc/misc.c -fno-common -DPIC -o .libs/misc.o define GC_STATIC_ASSERT(expr) (void)sizeof(char[(expr)? 1 : -1])
1 error generated. |
1 similar comment
On 29 Feb 2012, at 00:05, Boehm, Hans wrote:
I get that error (see below) when compiling bdwg from repository with clang (see below) in 64-bit mode, but not in 32-bit mode. It compiles using llvm-gcc (see below) in 64-bitmode. When running clang on this program: Hans It is the clang one gets from latest Xvcode 4.3 developer package on OS X 10.7.3: LLVM-GCC: Makefile error: libtool: compile: clang -DHAVE_CONFIG_H -I./include -I../bdwgc/include -I./libatomic_ops/src -I../bdwgc/libatomic_ops/src -fexceptions -Wall -Wextra -g -O2 -fno-strict-aliasing -MT misc.lo -MD -MP -MF .deps/misc.Tpo -c ../bdwgc/misc.c -fno-common -DPIC -o .libs/misc.o define GC_STATIC_ASSERT(expr) (void)sizeof(char[(expr)? 1 : -1])
1 error generated. |
On 29 Feb 2012, at 00:05, Boehm, Hans wrote:
It seems to be a bug in 64-bit clang. I have run the program below, made by replacing the compiling line of the file misc.c with preprocessing, on various compilers. All produce the output The compilers I tried were (In this version of Xcode, /usr/bin/cc -> clang and /usr/bin/gcc -> llvm-gcc-4.2. Before that, also /usr/bin/cc pointed to llvm. So packages that call for cc, now will use clang instead of llvm-gcc.) I also tried gcc-4.7 from the repository Hans ---- clang_test.c ---- #include <stdio.h> typedef unsigned long word; int main() { int k = ((ptr_t)(word)(-1) > (ptr_t)0)? 1 : -1; printf("%d, %d\n", k, l); |
1 similar comment
On 29 Feb 2012, at 00:05, Boehm, Hans wrote:
It seems to be a bug in 64-bit clang. I have run the program below, made by replacing the compiling line of the file misc.c with preprocessing, on various compilers. All produce the output The compilers I tried were (In this version of Xcode, /usr/bin/cc -> clang and /usr/bin/gcc -> llvm-gcc-4.2. Before that, also /usr/bin/cc pointed to llvm. So packages that call for cc, now will use clang instead of llvm-gcc.) I also tried gcc-4.7 from the repository Hans ---- clang_test.c ---- #include <stdio.h> typedef unsigned long word; int main() { int k = ((ptr_t)(word)(-1) > (ptr_t)0)? 1 : -1; printf("%d, %d\n", k, l); |
That sounds like a good explanation. You checked that word and ptr_t are defined correctly for the 64-bit setting? Hans B.
|
1 similar comment
That sounds like a good explanation. You checked that word and ptr_t are defined correctly for the 64-bit setting? Hans B.
|
On 1 Mar 2012, at 01:43, Boehm, Hans wrote:
The values are those that I got from preprocessing with clang in 64-bit mode, the case that failed. When you say it, they could be defined differently in the other compiles that worked, for example in 32-but mode. But Strictly speaking it is Hans |
1 similar comment
On 1 Mar 2012, at 01:43, Boehm, Hans wrote:
The values are those that I got from preprocessing with clang in 64-bit mode, the case that failed. When you say it, they could be defined differently in the other compiles that worked, for example in 32-but mode. But Strictly speaking it is Hans |
On 1 Mar 2012, at 01:43, Boehm, Hans wrote:
They are all defined the same, also in the 32-bit compile 'clang -arch i386'. Hans |
1 similar comment
On 1 Mar 2012, at 01:43, Boehm, Hans wrote:
They are all defined the same, also in the 32-bit compile 'clang -arch i386'. Hans |
On 1 Mar 2012, at 10:45, Ivan Maidanski wrote:
I filed a bug-report to Apple. Hans |
1 similar comment
On 1 Mar 2012, at 10:45, Ivan Maidanski wrote:
I filed a bug-report to Apple. Hans |
Hi Hans A., I've added a workaround for the bug to "release" branch - please test it. Regards. 01 03 2012, 21:43 Hans Aberg haberg-1@telia.com:
|
1 similar comment
Hi Hans A., I've added a workaround for the bug to "release" branch - please test it. Regards. 01 03 2012, 21:43 Hans Aberg haberg-1@telia.com:
|
Hi Hans A., This is known (caused by using deprecated API) but could anybody propose a fix for it? Regards. 04 03 2012, 15:55 Hans Aberg haberg-1@telia.com:
|
1 similar comment
Hi Hans A., This is known (caused by using deprecated API) but could anybody propose a fix for it? Regards. 04 03 2012, 15:55 Hans Aberg haberg-1@telia.com:
|
On 4 Mar 2012, at 13:15, Ivan Maidanski wrote:
As you note, it seems deprecated. The only difference between the structs mach_header_64 and mach_header is that the former has an added field which seems to do nothing (see below). So it may have been added in order to pay attention that it should not be used. The fix would be to not call _dyld_register_func_for_add_image() and _dyld_register_func_for_remove_image() in a 64-bit compile, since it will probably break. Hans /*
/* Constant for the magic field of the mach_header (32-bit architectures) / /*
/* Constant for the magic field of the mach_header_64 (64-bit architectures) / #define MH_CIGAM_64 0xcffaedfe /* NXSwapInt(MH_MAGIC_64) */ |
1 similar comment
On 4 Mar 2012, at 13:15, Ivan Maidanski wrote:
As you note, it seems deprecated. The only difference between the structs mach_header_64 and mach_header is that the former has an added field which seems to do nothing (see below). So it may have been added in order to pay attention that it should not be used. The fix would be to not call _dyld_register_func_for_add_image() and _dyld_register_func_for_remove_image() in a 64-bit compile, since it will probably break. Hans /*
/* Constant for the magic field of the mach_header (32-bit architectures) / /*
/* Constant for the magic field of the mach_header_64 (64-bit architectures) / #define MH_CIGAM_64 0xcffaedfe /* NXSwapInt(MH_MAGIC_64) */ |
Hi the community, 04 03 2012, 16:51 Hans Aberg haberg-1@telia.com:
I'd like also to hear opinion about this from other Darwin experts. Regards.
|
1 similar comment
Hi the community, 04 03 2012, 16:51 Hans Aberg haberg-1@telia.com:
I'd like also to hear opinion about this from other Darwin experts. Regards.
|
On 1 Mar 2012, at 18:41, Hans Aberg wrote:
Apple has now fixed this problem for all 'clang' compilers that come with Xcode 4.5. Specifically, the program below, both when using 'xcrun' (later compiler on Mac OS 10.7), and using 32- and 64-bit modes, now produces the output Hans #include <stdio.h> typedef unsigned long word; int main() { int k = ((ptr_t)(word)(-1) > (ptr_t)0)? 1 : -1; printf("%d, %d\n", k, l); } |
1 similar comment
On 1 Mar 2012, at 18:41, Hans Aberg wrote:
Apple has now fixed this problem for all 'clang' compilers that come with Xcode 4.5. Specifically, the program below, both when using 'xcrun' (later compiler on Mac OS 10.7), and using 32- and 64-bit modes, now produces the output Hans #include <stdio.h> typedef unsigned long word; int main() { int k = ((ptr_t)(word)(-1) > (ptr_t)0)? 1 : -1; printf("%d, %d\n", k, l); } |
Users of Homebrew have noticed the following problems when compiling with the default clang: 1 and 2.
The issue seems to be around the following macro:
Nobody is quite sure what that macro is intended to be doing (whether it is a bug in clang or a bug in the macro which clang exposes), but in either case it seems like something we should report upstream.
It compiles cleanly with LLVM.
The text was updated successfully, but these errors were encountered: