From: John Marino Date: Wed, 5 Nov 2014 21:48:48 +0000 (+0100) Subject: crt1.o: Fix compilation failure with -DGCRT on clang X-Git-Tag: v4.2.0rc~1541 X-Git-Url: https://gitweb.dragonflybsd.org/~tuxillo/dragonfly.git/commitdiff_plain/98b5f2ced1473d884397cff7d822d7b2187a78e3 crt1.o: Fix compilation failure with -DGCRT on clang Clang has been failing to compile the crt1.c with GCRT macro defined. The error message stated the "eprol" label was being defined twice. Clang was performing an alternative conditional optimization which duplicated the assembly including our inserted eprol label. The workaround is to relocate the eprol label after the handle_static_init function to get it out of the optimization loop. The trade-off of this workaround is that handle_static_init() can no longer be profiled. The formerly preceding monstartup belongs to gmon and it controls the range of PCs the profiling code considers. Suggested by: dillon --- diff --git a/lib/csu/x86_64/crt1.c b/lib/csu/x86_64/crt1.c index d1acef8460..f37b3ba952 100644 --- a/lib/csu/x86_64/crt1.c +++ b/lib/csu/x86_64/crt1.c @@ -73,9 +73,19 @@ _start(char **ap, void (*cleanup)(void)) #ifdef GCRT atexit(_mcleanup); monstartup(&eprol, &etext); -__asm__("eprol:"); #endif handle_static_init(argc, argv, env); +#ifdef GCRT + /* + * This label was previously located just after the monstartup + * function. It was relocated after the handle_static_init function + * to avoid an alternative conditional optimization performed by + * clang. The optimization cause the compilation to fail with a + * label redefinition error. The impact of the label relocation is + * the loss of profiling of handle_static_init function. + */ +__asm__("eprol:"); +#endif exit(main(argc, argv, env)); }