[Bug other/84257] New: Extremely slow compilation from gcc source code under macOS 10.13
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84257 Bug ID: 84257 Summary: Extremely slow compilation from gcc source code under macOS 10.13 Product: gcc Version: 7.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: 191919 at gmail dot com Target Milestone: --- In fact, this problem exists since very old version of gcc, but only in macOS 10.13 with SIP (System Integrity Protection) disabled. I upgraded my Mac from 10.12.6 to 10.13.3 and recompiled gcc, the compilation time is about 5 times longer. To be exactly, it is not the compilation which was slowed down, but the configure step. Every single output, like 'checking build system type... x86_64-apple-darwin17.4.0', takes more time than in 10.12.6. This check, 'checking compiler gcc -g ... yes' takes about 7 seconds. The entire compilation was unbearable SIX hours. I ran a lot of checks and found that this only happens when compiling gcc. Other autoconf based configure script, such as php and mysql, runs as fast as before. And even inside gcc, if I run configure for gmp or isl in a separated terminal session, it is still as fast as before. Finally I found the problem is caused by the DYLD_LIBRARY_PATH environment variable which during the configuration process is /mv/objs/./gmp/.libs:/mv/objs/./prev-gmp/.libs:/mv/objs/./mpfr/src/.libs:/mv/objs/./prev-mpfr/src/.libs:/mv/objs/./mpc/src/.libs:/mv/objs/./prev-mpc/src/.libs:/mv/objs/./isl/.libs:/mv/objs/./prev-isl/.libs:/mv/objs/x86_64-apple-darwin17.3.0/libstdc++-v3/src/.libs:/mv/objs/x86_64-apple-darwin17.3.0/libsanitizer/.libs:/mv/objs/x86_64-apple-darwin17.3.0/libcilkrts/.libs:/mv/objs/x86_64-apple-darwin17.3.0/libssp/.libs:/mv/objs/x86_64-apple-darwin17.3.0/libgomp/.libs:/mv/objs/x86_64-apple-darwin17.3.0/libitm/.libs:/mv/objs/x86_64-apple-darwin17.3.0/libatomic/.libs:/mv/objs/./gcc:/mv/objs/./prev-gcc (where /mv/objs is where I ran the configure script.) The change of value of DYLD_LIBRARY_PATH was introduced by the root Makefile ... $(RPATH_ENVVAR)=`echo "$(TARGET_LIB_PATH)$$$(RPATH_ENVVAR)" | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; export $(RPATH_ENVVAR); \ $(RPATH_ENVVAR)=`echo "$(HOST_LIB_PATH)$$$(RPATH_ENVVAR)" | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; export $(RPATH_ENVVAR); ... then exported, in macOS 10.13.3 with SIP enabled, the DYLD_LIBRARY_PATH environment variable will be automatically ignored, but my Mac has had SIP disabled, so DYLD_LIBRARY_PATH got exported and every single step after that, the mach-o loader will be affected. In macOS 10.12.6, even with SIP disabled, the compilation speed is not affected. I commented out this line in the root Makefile: RPATH_ENVVAR = DYLD_LIBRARY_PATH (BTW, in ChangeLog, I know this was brought by this: 2005-03-25 Paolo Bonzini * configure.in (RPATH_ENVVAR): Set to DYLD_LIBRARY_PATH on Darwin. * configure: Regenerate. ) and recompiled gcc, this time, it took only *30 minutes* (vs. 6 hours). I don't think setting RPATH_ENVVAR to DYLD_LIBRARY_PATH is necessary on modern macOS versions, please check.
[Bug bootstrap/84257] Extremely slow compilation from gcc source code under macOS 10.13
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84257 --- Comment #2 from 191919 <191919 at gmail dot com> --- I tried with the combination of the following settings under macOS 10.13.3: internal SSD / external HD HFS+ / APFS SIP enabled / SIP disabled The only factor that affects is SIP status. Once I disable it, DYLD_LIBRARY_PATH will be exported, then the scripts run slowly. I have reported the problem to Apple, but since turning off SIP is not recommended, I don't think they are going to fix it in short future.
[Bug bootstrap/84257] Extremely slow compilation from gcc source code under macOS 10.13
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84257 --- Comment #3 from 191919 <191919 at gmail dot com> --- In macOS 10.12.6 with SIP disabled, the value of DYLD_LIBRARY_PATH was modified to the same as in macOS 10.13.3, but the compilation speed was not affected. I guess this is a regression of macOS code to handle DYLD_LIBRARY_PATH in an SIP-disabled environment. Long since OS X El Capitan which introduced SIP (aka rootless), DYLD_LIBRARY_PATH was practically screened and no one complained about it, I think it is safe to say that the line #3 of the following code taken from configure.ac of gcc is not necessary and can be removed. 1 | case "${host}" in 2 | *-*-hpux*) RPATH_ENVVAR=SHLIB_PATH ;; 3 | *-*-darwin*) RPATH_ENVVAR=DYLD_LIBRARY_PATH ;; 4 | *-*-mingw* | *-*-cygwin ) RPATH_ENVVAR=PATH ;; 5 | *) RPATH_ENVVAR=LD_LIBRARY_PATH ;; 6 | esac
[Bug c/82200] New: Failed to use __asm under macOS 10.13
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82200 Bug ID: 82200 Summary: Failed to use __asm under macOS 10.13 Product: gcc Version: 7.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: 191919 at gmail dot com Target Milestone: --- I tried to compile the following source code: ``` #include int main() {} ``` with gcc-7.2.0 under macOS 10.13, I got these error messages: ``` In file included from /usr/include/sys/cdefs.h:587:0, from /usr/include/sys/syslog.h:65, from /usr/include/syslog.h:23, from sl.c:1: /usr/include/sys/syslog.h:227:124: error: expected ‘,’ or ‘;’ before ‘__asm’ void syslog(int, const char *, ...) __printflike(2, 3) __not_tail_called __DARWIN_ALIAS_STARTING(__MAC_10_13, __IPHONE_NA, __DARWIN_EXTSN(syslog)); ``` where __DARWIN_EXTSN is defined as: (in /usr/include/sys/cdefs.h) #define __DARWIN_EXTSN(sym) __asm("_" __STRING(sym) __DARWIN_SUF_EXTSN) It seems that __asm is not implemented. I compiled gcc-7.2.0 by this configuration: ../gcc-7.2.0/configure --prefix=/opt --enable-languages=c,c++,objc,obj-c++
[Bug c/82200] Failed to use __asm under macOS 10.13
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82200 --- Comment #2 from 191919 <191919 at gmail dot com> --- Yes, you are right. I rewrote the source file as below: ``` #include void msyslog(int, const char *, ...) __printflike(2, 3) __not_tail_called __DARWIN_ALIAS_STARTING(__MAC_10_13, __IPHONE_NA, __DARWIN_EXTSN(msyslog)); int main() {} ``` and generated the result file which got macros expanded: ``` /opt/bin/gcc -E -P test.c -o result.c ``` result.c: ``` void msyslog(int, const char *, ...) __attribute__((__format__ (__printf__, 2, 3))) __asm("_" "msyslog" "$DARWIN_EXTSN"); int main() {} ``` The compilation output is: ``` result.c:1:85: error: expected ‘,’ or ‘;’ before ‘__asm’ void msyslog(int, const char *, ...) __attribute__((__format__ (__printf__, 2, 3))) __asm("_" "msyslog" "$DARWIN_EXTSN"); ``` Xcode's cc can compile result.c without problem.