#attempted static link of dynamic object

1 messages · Page 1 of 1 (latest)

leaden tree
#

I am attempting to statically link the zig 0.10.0 compiler in Alpine Linux and I receive the following error:

52.98 [ 98%] Linking CXX executable zig1
58.31 /usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: attempted static link of dynamic object /usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../lib/liblldMinGW.so' ... 58.31 /usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: attempted static link of dynamic object /usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../lib/libstdc++.so'
58.31 /usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: attempted static link of dynamic object `/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../lib/libc.so'#9 64.11 collect2: error: ld returned 1 exit status
64.11 make[2]: *** [CMakeFiles/zig1.dir/build.make:305: zig1] Error 1
64.11 make[1]: *** [CMakeFiles/Makefile2:204: CMakeFiles/zig1.dir/all] Error 2
64.11 make: *** [Makefile:136: all] Error 2
ERROR: executor failed running [/bin/sh -c git clone --branch 0.10.0 --single-branch --depth 1 https://github.com/ziglang/zig.git && cd zig && mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/usr -DZIG_STATIC=ON .. && make -j $(nproc) install]: exit code: 2

My Dockerfile looks like the following:

FROM alpine:3.17.0
RUN apk add --no-cache build-base clang15-dev clang15-static cmake git libstdc++ libxml2-dev libxml2-static lld-dev llvm15-dev llvm15-static zlib-dev zlib-static
RUN git clone --branch 0.10.0 --single-branch --depth 1 https://github.com/ziglang/zig.git
&& cd zig
&& mkdir build
&& cd build
&& cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_PREFIX_PATH=/usr -DZIG_STATIC=ON ..
&& make -j $(nproc) install

Is there a dependency I am missing or a cmake flag I have missed?

placid warren
#

From a first look, libstdc++ is compiled with glibc/g++, not clang++.
However, I have no clue why you have a path /usr/lib/gcc/x86_64-alpine-linux-musl.
There should be no gcc installed.

leaden tree
#

I get the following error when I switch the default compiler to clang:

39.01 [ 95%] Building CXX object CMakeFiles/zigstage1.dir/src/stage1/tokenizer.cpp.o
39.13 [ 96%] Building CXX object CMakeFiles/zigstage1.dir/src/stage1/util.cpp.o
49.26 [ 97%] Linking CXX static library zigcpp/libzigstage1.a
49.29 [ 97%] Built target zigstage1
49.31 [ 98%] Building CXX object CMakeFiles/zig1.dir/src/stage1/zig0.cpp.o
49.50 [ 98%] Linking CXX executable zig1
50.26 /usr/bin/ld: attempted static link of dynamic object /usr/lib/liblldMinGW.so' 50.26 /usr/bin/ld: attempted static link of dynamic object /usr/lib/liblldELF.so'
50.26 /usr/bin/ld: attempted static link of dynamic object /usr/lib/liblldCOFF.so' 50.26 /usr/bin/ld: attempted static link of dynamic object /usr/lib/liblldWasm.so'
50.26 /usr/bin/ld: attempted static link of dynamic object /usr/lib/liblldMachO.so' 50.26 /usr/bin/ld: attempted static link of dynamic object /usr/lib/liblldCommon.so'
50.26 /usr/bin/ld: attempted static link of dynamic object /usr/lib/libxml2.so' 50.26 /usr/bin/ld: attempted static link of dynamic object /usr/lib/libstdc++.so'
50.26 /usr/bin/ld: attempted static link of dynamic object `/usr/lib/libc.so'
55.56 clang-15: error: linker command failed with exit code 1 (use -v to see invocation)
55.57 make[2]: *** [CMakeFiles/zig1.dir/build.make:305: zig1] Error 1
55.57 make[1]: *** [CMakeFiles/Makefile2:204: CMakeFiles/zig1.dir/all] Error 2
55.57 make: *** [Makefile:136: all] Error 2
ERROR: executor failed running [/bin/sh -c git clone --branch "${zig_version}" --single-branch --depth 1 https://github.com/ziglang/zig.git && cd zig && mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/usr -DZIG_STATIC=ON .. && make -j $(nproc) install]: exit code: 2

placid warren
#

copy prebuilt binaries to the Docker container rather than building them?
Docker does what you tell it. Its main purpose was a workaround to build complex applications, because state of the art for reproducible builds was very bad at that time for some languages.

#

exit code: 2
is very uninformative. Also, why do you have stage1/tokenizer.cpp.o ? Thats the now on master deleted stage1 compiler.

leaden tree
#

I'm building 0.10.0 - which doesn't have the wasm changes yet

#

I can try the master branch but I believe I was getting similar errors

leaden tree
#

I received this error with the master branch:

191.2 [ 85%] Building C object CMakeFiles/zig2.dir/zig2.c.o
191.2 [ 90%] Building C object CMakeFiles/zig2.dir/compiler_rt.c.o
241.2 [ 95%] Linking CXX executable zig2
253.8 [ 95%] Built target zig2
253.8 [100%] Building stage3
253.8 : CommandLine Error: Option 'xcore-max-threads' registered more than once!
253.8 LLVM ERROR: inconsistency in registered CommandLine options
253.8 make[2]: *** [CMakeFiles/stage3.dir/build.make:71: CMakeFiles/stage3] Aborted
253.8 make[1]: *** [CMakeFiles/Makefile2:196: CMakeFiles/stage3.dir/all] Error 2
253.8 make: *** [Makefile:136: all] Error 2

#

When I added -static to my CFLAGS and LDFLAGS, I received a different error on master:

190.5 [ 85%] Building C object CMakeFiles/zig2.dir/zig2.c.o
190.5 [ 90%] Building C object CMakeFiles/zig2.dir/compiler_rt.c.o
237.8 [ 95%] Linking CXX executable zig2
239.5 /usr/bin/ld: attempted static link of dynamic object /usr/lib/liblldMinGW.so' 239.5 /usr/bin/ld: attempted static link of dynamic object /usr/lib/liblldELF.so'
239.5 /usr/bin/ld: attempted static link of dynamic object /usr/lib/liblldCOFF.so' 239.5 /usr/bin/ld: attempted static link of dynamic object /usr/lib/liblldWasm.so'
239.5 /usr/bin/ld: attempted static link of dynamic object /usr/lib/liblldMachO.so' 239.5 /usr/bin/ld: attempted static link of dynamic object /usr/lib/liblldCommon.so'
239.5 /usr/bin/ld: attempted static link of dynamic object /usr/lib/libxml2.so' 239.5 /usr/bin/ld: attempted static link of dynamic object /usr/lib/libstdc++.so'
239.5 /usr/bin/ld: attempted static link of dynamic object `/usr/lib/libc.so'
249.7 clang-15: error: linker command failed with exit code 1 (use -v to see invocation)
249.7 make[2]: *** [CMakeFiles/zig2.dir/build.make:1158: zig2] Error 1
249.7 make[1]: *** [CMakeFiles/Makefile2:170: CMakeFiles/zig2.dir/all] Error 2
249.7 make: *** [Makefile:136: all] Error 2

leaden tree
#

I just know building llvm from source can take quite a bit of time