Open baszalmstra opened 8 years ago
(although it also happens without this)
What distribution are you on?
Im on Ubuntu Xenial
This is a clang issue. Linking with -L /usr/lib/gcc/<arch>-w64-mingw32/5.3-<posix|win32>
(i.e.: w32-clang test.c -L /usr/lib/gcc/i686-w64-mingw32/5.3-posix
) fixes the linker errors.
I will try to integrate this into wclang
within the next few days.
Awesome thanks!
Getting similar under Debian 8. However, for me it is:
/usr/bin/i686-w64-mingw32-ld: cannot find -lgcc
/usr/bin/i686-w64-mingw32-ld: cannot find -lgcc_eh
/usr/bin/i686-w64-mingw32-ld: cannot find -lgcc
/usr/bin/i686-w64-mingw32-ld: cannot find -lgcc_eh
Your suggestion helped me, too - thanks for that.
Mm, with the new version I still have this issue. I've got a docker image that reproduces this issue. Maybe it's something I'm doing wrong with the configuration.
FROM ubuntu:xenial
# Install dependencies for MXE + Clang3.8
RUN apt-get update && apt-get -y install \
autoconf automake autopoint bash bison bzip2 flex gettext\
git g++ gperf intltool libffi-dev libgdk-pixbuf2.0-dev \
libtool libltdl-dev libssl-dev libxml-parser-perl make \
openssl p7zip-full patch perl pkg-config python ruby scons \
sed unzip wget xz-utils g++-multilib libc6-dev-i386 libtool-bin \
clang clang-3.8
# WINE is used as an emulator for try_run and tests with CMake.
RUN dpkg --add-architecture i386 && \
apt-get update && \
apt-get install -y wine
ENV WINEARCH win64
RUN wine hostname
# mxe master 2016-05-10
WORKDIR /usr/src
RUN git clone https://github.com/mxe/mxe.git && \
cd mxe && \
git checkout 41aa9fd5fcb482380a056939637b2f8c9fa83ec6
WORKDIR /usr/src/mxe
COPY settings.mk /usr/src/mxe/
RUN make gcc -j$(nproc)
ENV PATH ${PATH}:/usr/src/mxe/usr/bin
# Install cmake dependencies
RUN apt-get update && apt-get -y install \
build-essential \
git \
wget curl \
tar bzip2 gzip \
zlib1g-dev libncurses5-dev libcurl4-openssl-dev \
vim && \
apt-get -y clean
# Build and install CMake from source.
WORKDIR /usr/src
RUN wget https://cmake.org/files/v3.4/cmake-3.4.3.tar.gz && \
tar -xzvf cmake-3.4.3.tar.gz && \
mkdir cmake-build && cd cmake-build && \
/usr/src/cmake-3.4.3/bootstrap \
--parallel=$(nproc) \
--prefix=/usr && \
make -j$(nproc) && \
./bin/cmake -DCMAKE_USE_SYSTEM_CURL:BOOL=ON \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DCMAKE_USE_OPENSSL:BOOL=ON . && \
make install && \
cd .. && \
rm -rf cmake*
# Install wclang 2016-05-10
RUN git clone https://github.com/tpoechtrager/wclang.git && \
cd wclang && \
git checkout 4758df6f62dfc382ae19da4178e046954a2a9855 && \
cmake . && \
make -j$(nproc) && \
make install && \
cd .. && \
rm -rf wclang
I cloned this repository and ran:
w64-clang++ HelloWorld.cpp Hello/Speaker.cpp -ohello_world.exe -IHello -v
It results in:
clang version 3.8.0-2ubuntu3 (tags/RELEASE_380/final)
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: /usr/bin
"/usr/lib/llvm-3.8/bin/clang" -cc1 -triple x86_64-w64-windows-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name HelloWorld.cpp -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 -debugger-tuning=gdb -nostdsysteminc -nobuiltininc -resource-dir /usr/lib/llvm-3.8/bin/../lib/clang/3.8.0 -isystem /usr/bin/../lib/clang/3.8/include -isystem /usr/src/mxe/usr/x86_64-w64-mingw32.static/include -isystem /usr/src/mxe/usr/x86_64-w64-mingw32.static/include/../../../usr/lib/gcc/x86_64-w64-mingw32.static/4.9.3/include/c++ -isystem /usr/src/mxe/usr/x86_64-w64-mingw32.static/include/../../../usr/lib/gcc/x86_64-w64-mingw32.static/4.9.3/include/c++/x86_64-w64-mingw32.static -I Hello -internal-isystem /usr/x86_64-w64-mingw32/include/c++ -internal-isystem /usr/x86_64-w64-mingw32/include/c++/x86_64-w64-mingw32 -internal-isystem /usr/x86_64-w64-mingw32/include/c++/backward -internal-isystem /usr/x86_64-w64-mingw32/include/c++/ -internal-isystem /usr/x86_64-w64-mingw32/include/c++//x86_64-w64-mingw32 -internal-isystem /usr/x86_64-w64-mingw32/include/c++//backward -internal-isystem /usr/include/c++/ -internal-isystem /usr/include/c++//x86_64-w64-mingw32 -internal-isystem /usr/include/c++//backward -internal-isystem include/c++ -internal-isystem include/c++/x86_64-w64-mingw32 -internal-isystem include/c++/backward -fdeprecated-macro -fdebug-compilation-dir/usr/src/cmake-hello-world -ferror-limit 19 -fmessage-length 80 -fno-use-cxa-atexit -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/HelloWorld-e12222.o -x c++ HelloWorld.cpp
clang -cc1 version 3.8.0 based upon LLVM 3.8.0 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/include/c++"
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/include/c++/x86_64-w64-mingw32"
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/include/c++/backward"
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/include/c++/"
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/include/c++//x86_64-w64-mingw32"
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/include/c++//backward"
ignoring nonexistent directory "/usr/include/c++//x86_64-w64-mingw32"
ignoring nonexistent directory "/usr/include/c++//backward"
ignoring nonexistent directory "include/c++"
ignoring nonexistent directory "include/c++/x86_64-w64-mingw32"
ignoring nonexistent directory "include/c++/backward"
#include "..." search starts here:
#include <...> search starts here:
Hello
/usr/bin/../lib/clang/3.8/include
/usr/src/mxe/usr/x86_64-w64-mingw32.static/include
/usr/src/mxe/usr/x86_64-w64-mingw32.static/include/../../../usr/lib/gcc/x86_64-
w64-mingw32.static/4.9.3/include/c++
/usr/src/mxe/usr/x86_64-w64-mingw32.static/include/../../../usr/lib/gcc/x86_64-
w64-mingw32.static/4.9.3/include/c++/x86_64-w64-mingw32.static
/usr/include/c++
End of search list.
"/usr/lib/llvm-3.8/bin/clang" -cc1 -triple x86_64-w64-windows-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name Speaker.cpp -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 -debugger-tuning=gdb -nostdsysteminc -nobuiltininc -resource-dir /usr/lib/llvm-3.8/bin/../lib/clang/3.8.0 -isystem /usr/bin/../lib/clang/3.8/include -isystem /usr/src/mxe/usr/x86_64-w64-mingw32.static/include -isystem /usr/src/mxe/usr/x86_64-w64-mingw32.static/include/../../../usr/lib/gcc/x86_64-w64-mingw32.static/4.9.3/include/c++ -isystem /usr/src/mxe/usr/x86_64-w64-mingw32.static/include/../../../usr/lib/gcc/x86_64-w64-mingw32.static/4.9.3/include/c++/x86_64-w64-mingw32.static -I Hello -internal-isystem /usr/x86_64-w64-mingw32/include/c++ -internal-isystem /usr/x86_64-w64-mingw32/include/c++/x86_64-w64-mingw32 -internal-isystem /usr/x86_64-w64-mingw32/include/c++/backward -internal-isystem /usr/x86_64-w64-mingw32/include/c++/ -internal-isystem /usr/x86_64-w64-mingw32/include/c++//x86_64-w64-mingw32 -internal-isystem /usr/x86_64-w64-mingw32/include/c++//backward -internal-isystem /usr/include/c++/ -internal-isystem /usr/include/c++//x86_64-w64-mingw32 -internal-isystem /usr/include/c++//backward -internal-isystem include/c++ -internal-isystem include/c++/x86_64-w64-mingw32 -internal-isystem include/c++/backward -fdeprecated-macro -fdebug-compilation-dir /usr/src/cmake-hello-world -ferror-limit 19 -fmessage-length 80 -fno-use-cxa-atexit -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/Speaker-1d92c1.o -x c++ Hello/Speaker.cpp
clang -cc1 version 3.8.0 based upon LLVM 3.8.0 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/include/c++"
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/include/c++/x86_64-w64-mingw32"
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/include/c++/backward"
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/include/c++/"
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/include/c++//x86_64-w64-mingw32"
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/include/c++//backward"
ignoring nonexistent directory "/usr/include/c++//x86_64-w64-mingw32"
ignoring nonexistent directory "/usr/include/c++//backward"
ignoring nonexistent directory "include/c++"
ignoring nonexistent directory "include/c++/x86_64-w64-mingw32"
ignoring nonexistent directory "include/c++/backward"
#include "..." search starts here:
#include <...> search starts here:
Hello
/usr/bin/../lib/clang/3.8/include
/usr/src/mxe/usr/x86_64-w64-mingw32.static/include
/usr/src/mxe/usr/x86_64-w64-mingw32.static/include/../../../usr/lib/gcc/x86_64-
w64-mingw32.static/4.9.3/include/c++
/usr/src/mxe/usr/x86_64-w64-mingw32.static/include/../../../usr/lib/gcc/x86_64-
w64-mingw32.static/4.9.3/include/c++/x86_64-w64-mingw32.static
/usr/include/c++
End of search list.
"/usr/bin/x86_64-w64-mingw32.static-ld" -m i386pep -Bdynamic -o hello_world.exe crt2.o crtbegin.o -L/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/4.9.3 -L/usr/x86_64-w64-mingw32/lib -L/usr/lib -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib /tmp/HelloWorld-e12222.o /tmp/Speaker-1d92c1.o -lstdc++ -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.static-ld: cannot find crt2.o: No such file or directory
/usr/bin/x86_64-w64-mingw32.static-ld: cannot find crtbegin.o: No such file or directory
/usr/bin/x86_64-w64-mingw32.static-ld: cannot find -lgcc_s
/usr/bin/x86_64-w64-mingw32.static-ld: cannot find -lgcc_s
/usr/bin/x86_64-w64-mingw32.static-ld: cannot find crtend.o: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Adding -wc-use-mingw-linker
solves the issue. And I get a proper functioning exe.
Any clues on what I'm missing? Any help would be greatly appreciated.
I can't work around the cannot find crt2.o: No such file or directory
issue. You must report it to the llvm people if you want to have it fixed. Or try Clang <= 3.6.
Mm Ill do that.. But what about the gcc_s?
For completeness, here is the output when I add -wc-use-mingw-linker
:
w64-clang++ HelloWorld.cpp Hello/Speaker.cpp -IHello -ohello_world.exe -wc-use-mingw-linker -v
Using built-in specs.
COLLECT_GCC=/usr/bin/x86_64-w64-mingw32.static-g++
COLLECT_LTO_WRAPPER=/usr/src/mxe/usr/libexec/gcc/x86_64-w64-mingw32.static/5.3.0/lto-wrapper
Target: x86_64-w64-mingw32.static
Configured with: /usr/src/mxe/tmp-gcc-x86_64-w64-mingw32.static/gcc-5.3.0/configure --target=x86_64-w64-mingw32.static --build=x86_64-unknown-linux-gnu --prefix=/usr/src/mxe/usr --libdir=/usr/src/mxe/usr/lib --enable-languages=c,c++,objc,fortran --enable-version-specific-runtime-libs --with-gcc --with-gnu-ld --with-gnu-as --disable-nls --disable-shared --disable-multilib --without-x --disable-win32-registry --enable-threads=win32 --enable-libgomp --with-gmp=/usr/src/mxe/usr/x86_64-unknown-linux-gnu --with-isl=/usr/src/mxe/usr/x86_64-unknown-linux-gnu --with-mpc=/usr/src/mxe/usr/x86_64-unknown-linux-gnu --with-mpfr=/usr/src/mxe/usr/x86_64-unknown-linux-gnu --with-cloog=/usr/src/mxe/usr/x86_64-unknown-linux-gnu --with-as=/usr/src/mxe/usr/bin/x86_64-w64-mingw32.static-as --with-ld=/usr/src/mxe/usr/bin/x86_64-w64-mingw32.static-ld --with-nm=/usr/src/mxe/usr/bin/x86_64-w64-mingw32.static-nm
Thread model: win32
gcc version 5.3.0 (GCC)
COLLECT_GCC_OPTIONS='-L/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0' '-I' 'Hello' '-o' 'hello_world.exe' '-v' '-mtune=generic' '-march=x86-64'
/usr/src/mxe/usr/libexec/gcc/x86_64-w64-mingw32.static/5.3.0/cc1plus -quiet -v -I Hello -U_REENTRANT HelloWorld.cpp -quiet -dumpbase HelloWorld.cpp -mtune=generic -march=x86-64 -auxbase HelloWorld -version -o /tmp/ccxagdVV.s
GNU C++ (GCC) version 5.3.0 (x86_64-w64-mingw32.static)
compiled by GNU C version 5.3.1 20160413, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/../../../../x86_64-w64-mingw32.static/sys-include"
#include "..." search starts here:
#include <...> search starts here:
Hello
/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/include/c++
/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/include/c++/x86_64-w64-mingw32.static
/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/include/c++/backward
/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/include
/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/include-fixed
/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/../../../../x86_64-w64-mingw32.static/include
End of search list.
GNU C++ (GCC) version 5.3.0 (x86_64-w64-mingw32.static)
compiled by GNU C version 5.3.1 20160413, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 4526b21d75da18c16f53522d1e53202b
COLLECT_GCC_OPTIONS='-L/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0' '-I' 'Hello' '-o' 'hello_world.exe' '-v' '-mtune=generic' '-march=x86-64'
/usr/src/mxe/usr/bin/x86_64-w64-mingw32.static-as -v -I Hello -o /tmp/ccwiuB4v.o /tmp/ccxagdVV.s
GNU assembler version 2.25.1 (x86_64-w64-mingw32.static) using BFD version (GNU Binutils) 2.25.1
COLLECT_GCC_OPTIONS='-L/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0' '-I' 'Hello' '-o' 'hello_world.exe' '-v' '-mtune=generic' '-march=x86-64'
/usr/src/mxe/usr/libexec/gcc/x86_64-w64-mingw32.static/5.3.0/cc1plus -quiet -v -I Hello -U_REENTRANT Hello/Speaker.cpp -quiet -dumpbase Speaker.cpp -mtune=generic -march=x86-64 -auxbase Speaker -version -o /tmp/ccxagdVV.s
GNU C++ (GCC) version 5.3.0 (x86_64-w64-mingw32.static)
compiled by GNU C version 5.3.1 20160413, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/../../../../x86_64-w64-mingw32.static/sys-include"
#include "..." search starts here:
#include <...> search starts here:
Hello
/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/include/c++
/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/include/c++/x86_64-w64-mingw32.static
/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/include/c++/backward
/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/include
/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/include-fixed
/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/../../../../x86_64-w64-mingw32.static/include
End of search list.
GNU C++ (GCC) version 5.3.0 (x86_64-w64-mingw32.static)
compiled by GNU C version 5.3.1 20160413, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 4526b21d75da18c16f53522d1e53202b
COLLECT_GCC_OPTIONS='-L/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0' '-I' 'Hello' '-o' 'hello_world.exe' '-v' '-mtune=generic' '-march=x86-64'
/usr/src/mxe/usr/bin/x86_64-w64-mingw32.static-as -v -I Hello -o /tmp/ccKAUif7.o /tmp/ccxagdVV.s
GNU assembler version 2.25.1 (x86_64-w64-mingw32.static) using BFD version (GNU Binutils) 2.25.1
COMPILER_PATH=/usr/src/mxe/usr/libexec/gcc/x86_64-w64-mingw32.static/5.3.0/:/usr/src/mxe/usr/libexec/gcc/x86_64-w64-mingw32.static/5.3.0/:/usr/src/mxe/usr/libexec/gcc/x86_64-w64-mingw32.static/:/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/:/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/:/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/../../../../x86_64-w64-mingw32.static/bin/
LIBRARY_PATH=/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/:/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/../../../../x86_64-w64-mingw32.static/lib/../lib/:/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/../../../../x86_64-w64-mingw32.static/lib/
COLLECT_GCC_OPTIONS='-L/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0' '-I' 'Hello' '-o' 'hello_world.exe' '-v' '-mtune=generic' '-march=x86-64'
/usr/src/mxe/usr/libexec/gcc/x86_64-w64-mingw32.static/5.3.0/collect2 -plugin /usr/src/mxe/usr/libexec/gcc/x86_64-w64-mingw32.static/5.3.0/liblto_plugin.so -plugin-opt=/usr/src/mxe/usr/libexec/gcc/x86_64-w64-mingw32.static/5.3.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccbsEewI.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -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=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -m i386pep -Bdynamic -o hello_world.exe /usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/../../../../x86_64-w64-mingw32.static/lib/../lib/crt2.o /usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/crtbegin.o -L/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0 -L/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0 -L/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/../../../../x86_64-w64-mingw32.static/lib/../lib -L/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/../../../../x86_64-w64-mingw32.static/lib /tmp/ccwiuB4v.o /tmp/ccKAUif7.o -lstdc++ -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt /usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/crtend.o
What I find interesting is that here a path is added to the crt2.o
(/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/../../../../x86_64-w64-mingw32.static/lib/../lib/crt2.o
) etc files. Is clang responsible for the call to collect or wclang?
I also tried to use clang 3.6 but ran into the exact same issue. It really feels like I'm configuring something incorrectly but I can't seem to spot it...
Trying with ubuntu thrusty and clang 3.5 next.
It works like a charm under Ubuntu trusty. What has changed?
Mm Ill do that.. But what about the gcc_s?
I could theoretically work around the gcc_s
issue, but it makes no sense because the crt2.o
error won't go away that way.
Is clang responsible for the call to collect or wclang? It works like a charm under Ubuntu trusty. What has changed?
Clang up until 3.6 invokes gcc when linking is done - -wc-use-mingw-linker
is doing the same (but explicitly: wclang -> gcc
instead of wclang -> clang -> gcc
). Do not compile source files with -wc-use-mingw-linker
.
I also tried to use clang 3.6 but ran into the exact same issue. It really feels like I'm configuring something incorrectly but I can't seem to spot it...
Are you sure wclang is using Clang 3.6...?
It was wrong in my previous statement. It has nothing to do with the distribution. As expected from your previous post it works fine with clang 3.5. I did some more thorough testing and found that without MXE it works flawlessly with Ubuntu Xenial Xerus + Clang 3.8.
I found out that the crt2.o
etc files are properly linked when mingw-w64
is installed alongside MXE. I was under the assumption that MXE installed mingw-w64
.
When I build MXE and add it to the path I now only get that -lgcc_s
cannot be found:
clang version 3.8.0-2ubuntu3 (tags/RELEASE_380/final)
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: /usr/bin
"/usr/lib/llvm-3.8/bin/clang" -cc1 -triple x86_64-w64-windows-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name HelloWorld.cpp -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 -debugger-tuning=gdb -nostdsysteminc -nobuiltininc -resource-dir /usr/lib/llvm-3.8/bin/../lib/clang/3.8.0 -isystem /usr/bin/../lib/clang/3.8/include -isystem /usr/src/mxe/usr/x86_64-w64-mingw32.static/include -isystem /usr/src/mxe/usr/x86_64-w64-mingw32.static/include/../../../usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/include/c++ -isystem /usr/src/mxe/usr/x86_64-w64-mingw32.static/include/../../../usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/include/c++/x86_64-w64-mingw32.static -I Hello -internal-isystem /usr/x86_64-w64-mingw32/include/c++ -internal-isystem /usr/x86_64-w64-mingw32/include/c++/x86_64-w64-mingw32 -internal-isystem /usr/x86_64-w64-mingw32/include/c++/backward -internal-isystem /usr/x86_64-w64-mingw32/include/c++/ -internal-isystem /usr/x86_64-w64-mingw32/include/c++//x86_64-w64-mingw32 -internal-isystem /usr/x86_64-w64-mingw32/include/c++//backward -internal-isystem /usr/include/c++/ -internal-isystem /usr/include/c++//x86_64-w64-mingw32 -internal-isystem /usr/include/c++//backward -internal-isystem include/c++ -internal-isystem include/c++/x86_64-w64-mingw32 -internal-isystem include/c++/backward -fdeprecated-macro -fdebug-compilation-dir /usr/src/cmake-hello-world -ferror-limit 19 -fmessage-length 0 -fno-use-cxa-atexit -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -o /tmp/HelloWorld-66163c.o -x c++ HelloWorld.cpp
clang -cc1 version 3.8.0 based upon LLVM 3.8.0 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/include/c++"
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/include/c++/x86_64-w64-mingw32"
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/include/c++/backward"
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/include/c++/"
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/include/c++//x86_64-w64-mingw32"
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/include/c++//backward"
ignoring nonexistent directory "/usr/include/c++//x86_64-w64-mingw32"
ignoring nonexistent directory "/usr/include/c++//backward"
ignoring nonexistent directory "include/c++"
ignoring nonexistent directory "include/c++/x86_64-w64-mingw32"
ignoring nonexistent directory "include/c++/backward"
#include "..." search starts here:
#include <...> search starts here:
Hello
/usr/bin/../lib/clang/3.8/include
/usr/src/mxe/usr/x86_64-w64-mingw32.static/include
/usr/src/mxe/usr/x86_64-w64-mingw32.static/include/../../../usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/include/c++
/usr/src/mxe/usr/x86_64-w64-mingw32.static/include/../../../usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/include/c++/x86_64-w64-mingw32.static
/usr/include/c++
End of search list.
"/usr/lib/llvm-3.8/bin/clang" -cc1 -triple x86_64-w64-windows-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name Speaker.cpp -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 -debugger-tuning=gdb -nostdsysteminc -nobuiltininc -resource-dir /usr/lib/llvm-3.8/bin/../lib/clang/3.8.0 -isystem /usr/bin/../lib/clang/3.8/include -isystem /usr/src/mxe/usr/x86_64-w64-mingw32.static/include -isystem /usr/src/mxe/usr/x86_64-w64-mingw32.static/include/../../../usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/include/c++ -isystem /usr/src/mxe/usr/x86_64-w64-mingw32.static/include/../../../usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/include/c++/x86_64-w64-mingw32.static -I Hello -internal-isystem /usr/x86_64-w64-mingw32/include/c++ -internal-isystem /usr/x86_64-w64-mingw32/include/c++/x86_64-w64-mingw32 -internal-isystem /usr/x86_64-w64-mingw32/include/c++/backward -internal-isystem /usr/x86_64-w64-mingw32/include/c++/ -internal-isystem /usr/x86_64-w64-mingw32/include/c++//x86_64-w64-mingw32 -internal-isystem /usr/x86_64-w64-mingw32/include/c++//backward -internal-isystem /usr/include/c++/ -internal-isystem /usr/include/c++//x86_64-w64-mingw32 -internal-isystem /usr/include/c++//backward -internal-isystem include/c++ -internal-isystem include/c++/x86_64-w64-mingw32 -internal-isystem include/c++/backward -fdeprecated-macro -fdebug-compilation-dir /usr/src/cmake-hello-world -ferror-limit 19 -fmessage-length 0 -fno-use-cxa-atexit -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -o /tmp/Speaker-ae56e6.o -x c++ Hello/Speaker.cpp
clang -cc1 version 3.8.0 based upon LLVM 3.8.0 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/include/c++"
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/include/c++/x86_64-w64-mingw32"
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/include/c++/backward"
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/include/c++/"
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/include/c++//x86_64-w64-mingw32"
ignoring nonexistent directory "/usr/x86_64-w64-mingw32/include/c++//backward"
ignoring nonexistent directory "/usr/include/c++//x86_64-w64-mingw32"
ignoring nonexistent directory "/usr/include/c++//backward"
ignoring nonexistent directory "include/c++"
ignoring nonexistent directory "include/c++/x86_64-w64-mingw32"
ignoring nonexistent directory "include/c++/backward"
#include "..." search starts here:
#include <...> search starts here:
Hello
/usr/bin/../lib/clang/3.8/include
/usr/src/mxe/usr/x86_64-w64-mingw32.static/include
/usr/src/mxe/usr/x86_64-w64-mingw32.static/include/../../../usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/include/c++
/usr/src/mxe/usr/x86_64-w64-mingw32.static/include/../../../usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0/include/c++/x86_64-w64-mingw32.static
/usr/include/c++
End of search list.
"/usr/bin/x86_64-w64-mingw32.static-ld" -m i386pep -Bdynamic -o hello_world.exe /usr/x86_64-w64-mingw32/lib/crt2.o /usr/x86_64-w64-mingw32/lib/crtbegin.o -L/usr/src/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.3.0 -L/usr/x86_64-w64-mingw32/lib -L/usr/lib -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib /tmp/HelloWorld-66163c.o /tmp/Speaker-ae56e6.o -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt /usr/x86_64-w64-mingw32/lib/crtend.o
/usr/bin/x86_64-w64-mingw32.static-ld: cannot find -lgcc_s
/usr/bin/x86_64-w64-mingw32.static-ld: cannot find -lgcc_s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
without MXE it works flawlessly with Ubuntu Xenial Xerus + Clang 3.8.
That's what I have fixed.
I found out that the crt2.o etc files are properly linked when mingw-w64 is installed alongside MXE.
That shows how broken Clang's new MinGW driver is... MXE and mingw-w64 are different toolchains (x86_64-w64-mingw32.static
!= x86_64-w64-mingw32
). You shouldn't mix them.
/usr/include/c++
Shouldn't be there either.
I was under the assumption that MXE installed mingw-w64.
MXE has indeed its own CRT objs.
So what do you recommend? I can probably go without MXE for now but what would be the right course of action to get this stuff working? What is actually going wrong that I can report to the llvm folks?
So what do you recommend? I can probably go without MXE for now but what would be the right course of action to get this stuff working?
Either go with Clang <= 3.6 + MXE or with Clang 3.8 + the system's MinGW distribution.
What is actually going wrong that I can report to the llvm folks?
Clang's "new" MinGW driver fails to find the CRT object files and seems to ignore the fact that x86_64-w64-mingw32.static
and x86_64-w64-mingw32
are different toolchains.
Everytime I try to build something simple I always run into this issue:
When I add -wc-use-mingw-linker however I can compile without issues. I've followed some steps I found in issues here like setting the COMPILER_PATH, but it doesn't fix the problem. I'm using MXE (although it also happens without this), and clang 3.8.
Any help would be greatly appreciated!