Hi, Not really answering your questions but I think the problem is clang is invoking $TARGET-ld directly, it used to let gcc link so gcc would figure out the linker details. See a run with clang 3.6.1 on same setup:
λ /usr/bin/clang -v -target x86_64-w64-mingw32 -isystem /usr/x86_64-w64-mingw32/sys-root/x86_64-w64-mingw32/include randomworks/windows/nic.c -liphlpapi clang version 3.6.1 (tags/RELEASE_361/final 238133) Target: x86_64-w64-windows-gnu Thread model: posix "/usr/bin/clang-3.6" -cc1 -triple x86_64-w64-windows-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name nic.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -v -dwarf-column-info -resource-dir /usr/bin/../lib64/clang/3.6.1 -isystem /usr/x86_64-w64-mingw32/sys-root/x86_64-w64-mingw32/include -fdebug-compilation-dir /home/ismail -ferror-limit 19 -fmessage-length 126 -mstackrealign -fno-use-cxa-atexit -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/nic-e31eb1.o -x c randomworks/windows/nic.c clang -cc1 version 3.6.1 based upon LLVM 3.6.1 default target x86_64-suse-linux ignoring nonexistent directory "/usr/bin/../lib64/clang/3.6.1/../../../i686-w64-mingw32/include" ignoring nonexistent directory "/usr/bin/../lib64/clang/3.6.1/../../../x86_64-w64-mingw32/include" ignoring nonexistent directory "/mingw/include" ignoring duplicate directory "/usr/bin/../lib64/clang/3.6.1/../../../include" #include "..." search starts here: #include <...> search starts here: /usr/x86_64-w64-mingw32/sys-root/x86_64-w64-mingw32/include /usr/local/include /usr/bin/../lib64/clang/3.6.1/include /usr/bin/../lib64/clang/3.6.1/../../../include End of search list. "/usr/bin/x86_64-w64-mingw32-gcc" -v -isystem /usr/x86_64-w64-mingw32/sys-root/x86_64-w64-mingw32/include -m64 -o a.exe /tmp/nic-e31eb1.o -liphlpapi Using built-in specs. COLLECT_GCC=/usr/bin/x86_64-w64-mingw32-gcc COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/lto-wrapper Target: x86_64-w64-mingw32 Configured with: ../configure --prefix=/usr --bindir=/usr/bin --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/lib64 --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --build=x86_64-suse-linux-gnu --host=x86_64-suse-linux-gnu --target=x86_64-w64-mingw32 --with-gnu-as --with-gnu-ld --verbose --without-newlib --disable-multilib --disable-plugin --with-system-zlib --disable-nls --without-included-gettext --disable-win32-registry --enable-version-specific-runtime-libs --with-sysroot=/usr/x86_64-w64-mingw32/sys-root --enable-languages=c,c++,fortran,objc,obj-c++ --without-x --enable-hash-synchronization --enable-fully-dynamic-string --enable-libgomp --enable-linker-build-id Thread model: win32 gcc version 5.1.0 (GCC) COMPILER_PATH=/usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/:/usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/:/usr/lib64/gcc/x86_64-w64-mingw32/:/usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/:/usr/lib64/gcc/x86_64-w64-mingw32/:/usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ LIBRARY_PATH=/usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/:/usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/lib/../lib/:/usr/x86_64-w64-mingw32/sys-root/mingw/lib/../lib/:/usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/lib/:/usr/x86_64-w64-mingw32/sys-root/mingw/lib/ COLLECT_GCC_OPTIONS='-v' '-isystem' '/usr/x86_64-w64-mingw32/sys-root/x86_64-w64-mingw32/include' '-m64' '-o' 'a.exe' '-mtune=generic' '-march=x86-64' /usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/collect2 -plugin /usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/liblto_plugin.so -plugin-opt=/usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccd7Jm2a.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt --sysroot=/usr/x86_64-w64-mingw32/sys-root --build-id -m i386pep -Bdynamic -o a.exe /usr/x86_64-w64-mingw32/sys-root/mingw/lib/../lib/crt2.o /usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/crtbegin.o -L/usr/lib64/gcc/x86_64-w64-mingw32/5.1.0 -L/usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/lib/../lib -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib/../lib -L/usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/lib -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib /tmp/nic-e31eb1.o -liphlpapi -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt /usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/crtend.o On Fri, Jul 10, 2015 at 9:55 PM, Yaron Keren <yaron.ke...@gmail.com> wrote: > OK, please help me understand, > > Where are the include directories? > Where are the lib directories? > Is gcc on the path? where? > Should clang have a default hardcoed sysroot location on Linux which is not > based on clang installed location? > > > 2015-07-10 21:45 GMT+03:00 İsmail Dönmez <ism...@donmez.ws>: >> >> The problem is this exact command line worked since forever and only >> recently regressed thats why I report it. >> >> On Fri, Jul 10, 2015 at 9:38 PM, Yaron Keren <yaron.ke...@gmail.com> >> wrote: >> > clang can locate /usr/x86_64-w64-mingw32/sys-root if provided to the >> > -sysroot option or deduce sysroot automatically if it finds >> > /usr/x86_64-w64-mingw32/sys-root/bin/gcc binary on the path. >> > >> > clang does not deduce the sysroot from the -isystem directory by itself. >> > >> > >> > >> > >> > 2015-07-10 19:57 GMT+03:00 İsmail Dönmez <ism...@donmez.ws>: >> >> >> >> Anyhow this is not a nice example since it uses Cygwin's ld. A better >> >> example from Linux side: >> >> >> >> λ clang -v -target x86_64-w64-mingw32 -isystem >> >> /usr/x86_64-w64-mingw32/sys-root/x86_64-w64-mingw32/include >> >> randomworks/windows/nic.c >> >> clang version 3.7.0 (trunk 241471) >> >> Target: x86_64-w64-windows-gnu >> >> Thread model: posix >> >> "/opt/clang/bin/clang-3.7" -cc1 -triple x86_64-w64-windows-gnu >> >> -emit-obj -mrelax-all -disable-free -main-file-name nic.c >> >> -mrelocation-model pic -pic-level 2 -mthread-model posix -fmath-errno >> >> -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 >> >> -momit-leaf-frame-pointer -v -dwarf-column-info -resource-dir >> >> /opt/clang/bin/../lib64/clang/3.7.0 -isystem >> >> /usr/x86_64-w64-mingw32/sys-root/x86_64-w64-mingw32/include >> >> -internal-isystem /opt/clang/bin/../lib64/clang/3.7.0/include >> >> -internal-isystem include -internal-isystem include-fixed >> >> -internal-isystem /usr/mingw32/include -internal-isystem /usr/include >> >> -fdebug-compilation-dir /home/ismail -ferror-limit 19 -fmessage-length >> >> 126 -mstackrealign -fno-use-cxa-atexit -fobjc-runtime=gcc >> >> -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/nic-08e945.o -x >> >> c randomworks/windows/nic.c >> >> clang -cc1 version 3.7.0 based upon LLVM 3.7.0svn default target >> >> x86_64-suse-linux >> >> ignoring nonexistent directory "include" >> >> ignoring nonexistent directory "include-fixed" >> >> ignoring nonexistent directory "/usr/mingw32/include" >> >> #include "..." search starts here: >> >> #include <...> search starts here: >> >> /usr/x86_64-w64-mingw32/sys-root/x86_64-w64-mingw32/include >> >> /opt/clang/bin/../lib64/clang/3.7.0/include >> >> /usr/include >> >> End of search list. >> >> "/usr/bin/x86_64-w64-mingw32-ld" -m i386pep -Bdynamic -o a.exe crt2.o >> >> crtbegin.o -L -L/usr/lib -L/usr/mingw32/lib /tmp/nic-08e945.o >> >> -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 >> >> -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname >> >> -lmingwex -lmsvcrt crtend.o >> >> /usr/bin/x86_64-w64-mingw32-ld: cannot find crt2.o: No such file or >> >> directory >> >> /usr/bin/x86_64-w64-mingw32-ld: cannot find crtbegin.o: No such file >> >> or directory >> >> /usr/bin/x86_64-w64-mingw32-ld: cannot find -lmingw32 >> >> /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgcc_s >> >> /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgcc >> >> /usr/bin/x86_64-w64-mingw32-ld: cannot find -lmoldname >> >> /usr/bin/x86_64-w64-mingw32-ld: cannot find -lmingwex >> >> /usr/bin/x86_64-w64-mingw32-ld: cannot find -lmsvcrt >> >> /usr/bin/x86_64-w64-mingw32-ld: cannot find -ladvapi32 >> >> /usr/bin/x86_64-w64-mingw32-ld: cannot find -lshell32 >> >> /usr/bin/x86_64-w64-mingw32-ld: cannot find -luser32 >> >> /usr/bin/x86_64-w64-mingw32-ld: cannot find -lkernel32 >> >> /usr/bin/x86_64-w64-mingw32-ld: cannot find -lmingw32 >> >> /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgcc_s >> >> /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgcc >> >> /usr/bin/x86_64-w64-mingw32-ld: cannot find -lmoldname >> >> /usr/bin/x86_64-w64-mingw32-ld: cannot find -lmingwex >> >> /usr/bin/x86_64-w64-mingw32-ld: cannot find -lmsvcrt >> >> /usr/bin/x86_64-w64-mingw32-ld: cannot find crtend.o: No such file or >> >> directory >> >> clang-3.7: error: linker command failed with exit code 1 (use -v to >> >> see invocation) >> >> >> >> >> >> On Fri, Jul 10, 2015 at 7:54 PM, İsmail Dönmez <ism...@donmez.ws> >> >> wrote: >> >> > This is without any patches (r241901-win64) and the original command >> >> > line is there: >> >> > >> >> > clang -v -target x86_64-w64-mingw32 -isystem >> >> > C:/mingw-w64-6.0.0/x86_64-w64-mingw32/include -isystem >> >> > C:/mingw-w64-6.0.0/include/c++/6.0.0 -isystem >> >> > C:/mingw-w64-6.0.0/include/c++/6.0.0/x86_64-w64-mingw32 >> >> > randomworks/windows/nic.c >> >> > >> >> > >> >> > On Fri, Jul 10, 2015 at 7:51 PM, Yaron Keren <yaron.ke...@gmail.com> >> >> > wrote: >> >> >> This is with or without any patches? what is the original command >> >> >> line? >> >> >> >> >> >> >> >> >> 2015-07-10 19:30 GMT+03:00 İsmail Dönmez <ism...@donmez.ws>: >> >> >>> >> >> >>> Hi, >> >> >>> >> >> >>> I meant to try these but both on cygwin and linux hosts we have >> >> >>> linking regression that goes like: >> >> >>> >> >> >>> λ clang -v -target x86_64-w64-mingw32 -isystem >> >> >>> C:/mingw-w64-6.0.0/x86_64-w64-mingw32/include -isystem >> >> >>> C:/mingw-w64-6.0.0/include/c++/6.0.0 -isystem >> >> >>> C:/mingw-w64-6.0.0/include/c++/6.0.0/x86_64-w64-mingw32 >> >> >>> randomworks/windows/nic.c >> >> >>> clang version 3.7.0 (https://github.com/llvm-mirror/clang.git >> >> >>> ca355c9f413a6ca4941e3033e89e5242e29bd802) >> >> >>> Target: x86_64-w64-windows-gnu >> >> >>> Thread model: posix >> >> >>> "C:\\Program Files\\LLVM\\bin\\clang.exe" -cc1 -triple >> >> >>> x86_64-w64-windows-gnu -emit-obj -mrelax-all -disable-free >> >> >>> -main-file-name nic.c -mrelocation-model pic -pic-level 2 >> >> >>> -mthread-model posix -fmath-errno -masm-verbose >> >> >>> -mconstructor-aliases >> >> >>> -munwind-tables -target-cpu x86-64 -momit-leaf-frame-pointer -v >> >> >>> -dwarf-column-info -resource-dir "C:\\Program >> >> >>> Files\\LLVM\\bin\\..\\lib\\clang\\3.7.0" -isystem >> >> >>> C:/mingw-w64-6.0.0/x86_64-w64-mingw32/include -isystem >> >> >>> C:/mingw-w64-6.0.0/include/c++/6.0.0 -isystem >> >> >>> C:/mingw-w64-6.0.0/include/c++/6.0.0/x86_64-w64-mingw32 >> >> >>> -internal-isystem "C:\\Program >> >> >>> Files\\LLVM\\bin\\..\\lib\\clang\\3.7.0\\include" -internal-isystem >> >> >>> include -internal-isystem include-fixed -internal-isystem >> >> >>> "C:\\cygwin64\\mingw32\\include" -internal-isystem >> >> >>> "C:\\cygwin64\\include" -std=c11 -fdebug-compilation-dir >> >> >>> "C:\\cygwin64\\home\\ismail" -ferror-limit 19 -fmessage-length 0 >> >> >>> -mstackrealign -fno-use-cxa-atexit -fobjc-runtime=gcc >> >> >>> -fdiagnostics-show-option -fcolor-diagnostics -fansi-escape-codes >> >> >>> -o >> >> >>> "C:\\cygwin64\\tmp\\nic-6bff3b.o" -x c randomworks/windows/nic.c >> >> >>> clang -cc1 version 3.7.0 based upon LLVM 3.7.0svn default target >> >> >>> x86_64-pc-windows-msvc >> >> >>> ignoring nonexistent directory "include" >> >> >>> ignoring nonexistent directory "include-fixed" >> >> >>> ignoring nonexistent directory "C:\cygwin64\mingw32\include" >> >> >>> ignoring nonexistent directory "C:\cygwin64\include" >> >> >>> #include "..." search starts here: >> >> >>> #include <...> search starts here: >> >> >>> C:/mingw-w64-6.0.0/x86_64-w64-mingw32/include >> >> >>> C:/mingw-w64-6.0.0/include/c++/6.0.0 >> >> >>> C:/mingw-w64-6.0.0/include/c++/6.0.0/x86_64-w64-mingw32 >> >> >>> C:\Program Files\LLVM\bin\..\lib\clang\3.7.0\include >> >> >>> End of search list. >> >> >>> "C:\\cygwin64\\bin\\ld.exe" -m i386pep -Bdynamic -o a.exe crt2.o >> >> >>> crtbegin.o -L "-LC:\\cygwin64\\lib" "-LC:\\cygwin64\\mingw32\\lib" >> >> >>> "C:\\cygwin64\\tmp\\nic-6bff3b.o" -lmingw32 -lgcc_s -lgcc >> >> >>> -lmoldname >> >> >>> -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 >> >> >>> -lmingw32 >> >> >>> -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt crtend.o >> >> >>> /usr/bin/ld: cannot find crt2.o: No such file or directory >> >> >>> /usr/bin/ld: cannot find crtbegin.o: No such file or directory >> >> >>> /usr/bin/ld: cannot find -lmingw32 >> >> >>> /usr/bin/ld: cannot find -lgcc_s >> >> >>> /usr/bin/ld: cannot find -lgcc >> >> >>> /usr/bin/ld: cannot find -lmoldname >> >> >>> /usr/bin/ld: cannot find -lmingwex >> >> >>> /usr/bin/ld: cannot find -lmsvcrt >> >> >>> /usr/bin/ld: cannot find -lmingw32 >> >> >>> /usr/bin/ld: cannot find -lgcc_s >> >> >>> /usr/bin/ld: cannot find -lgcc >> >> >>> /usr/bin/ld: cannot find -lmoldname >> >> >>> /usr/bin/ld: cannot find -lmingwex >> >> >>> /usr/bin/ld: cannot find -lmsvcrt >> >> >>> /usr/bin/ld: cannot find crtend.o: No such file or directory >> >> >>> clang.exe: error: linker command failed with exit code 1 (use -v to >> >> >>> see invocation) >> >> >>> >> >> >>> Any ideas? Also reproducible with gcc 5.1.1 on Linux. >> >> >>> >> >> >>> >> >> >>> On Tue, Jul 7, 2015 at 6:19 PM, Yaron Keren <yaron.ke...@gmail.com> >> >> >>> wrote: >> >> >>> > Here is a patch honoring sysroot for ld, let me know if it works >> >> >>> > for >> >> >>> > you. >> >> >>> > >> >> >>> > 2015-07-07 12:13 GMT+03:00 Yaron Keren <yaron.ke...@gmail.com>: >> >> >>> >> >> >> >>> >> Hi, Please see if the attached patch works on opensuse. >> >> >>> >> >> >> >>> >> I'll look at the cygnus ld issue later. >> >> >>> >> >> >> >>> >> >> >> >>> >> 2015-07-07 10:38 GMT+03:00 İsmail Dönmez <ism...@donmez.ws>: >> >> >>> >>> >> >> >>> >>> Hi, >> >> >>> >>> >> >> >>> >>> On Mon, Jul 6, 2015 at 10:40 AM, Yaron Keren >> >> >>> >>> <yaron.ke...@gmail.com> >> >> >>> >>> wrote: >> >> >>> >>> > Author: yrnkrn >> >> >>> >>> > Date: Mon Jul 6 02:40:10 2015 >> >> >>> >>> > New Revision: 241432 >> >> >>> >>> > >> >> >>> >>> > URL: http://llvm.org/viewvc/llvm-project?rev=241432&view=rev >> >> >>> >>> > Log: >> >> >>> >>> > Teach mingw toolchain the msys2 mingw-w64 distribution C++ >> >> >>> >>> > dirs. >> >> >>> >>> > >> >> >>> >>> > >> >> >>> >>> > Modified: >> >> >>> >>> > cfe/trunk/lib/Driver/MinGWToolChain.cpp >> >> >>> >>> > cfe/trunk/lib/Driver/ToolChains.h >> >> >>> >>> >> >> >>> >>> I tried this revision on openSUSE MinGW toolchain and its >> >> >>> >>> missing >> >> >>> >>> one >> >> >>> >>> include path, which is $GCC_ROOT/nclude/c++/x86_64-w64-mingw32 >> >> >>> >>> which >> >> >>> >>> contains "bits" and "ext" directories. Would you mind adding >> >> >>> >>> that >> >> >>> >>> to >> >> >>> >>> the list too? >> >> >>> >>> >> >> >>> >>> Thanks! >> >> >>> >> >> >> >>> >> >> >> >>> > >> >> >> >> >> >> >> > >> > > > _______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits