Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zig c++ fails when using -march (and -mtune) when using x86_64-linux-musl as target #9986

Open
1 task done
ghuls opened this issue Oct 20, 2021 · 4 comments
Open
1 task done
Labels
arch-x86_64 bug Observed behavior contradicts documented or intended behavior os-linux zig cc Zig as a drop-in C compiler feature
Milestone

Comments

@ghuls
Copy link

ghuls commented Oct 20, 2021

Remember to search before filing a new report

  • I searched for this bug and did not find it in the issue tracker, and furthermore, the title I used above will make this new bug report turn up in the search results for my query.

Zig Version

0.9.0-dev.1433+4a76523b9

Steps to Reproduce

zig c++ fails when using -march (and -mtune) when using x86_64-linux-musl as target.

git clone https://github.com/weng-lab/cluster-buster

cd cluster-buster

~/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/zig c++ -v -Wall -std=c++0x -O3 -march=x86_64_v3 -mtune=x86_64_v3 -D NDEBUG -target x86_64-linux-musl -D GIT_COMMIT_INFO="\"2020-05-07 10:30:42 -0400  commit: ac1d33c\"" -o cbust_amd *.cpp

Without -march and -mtune option it build fine. with those options, there are problems building MUSL: error: unable to build musl CRT file: BuildingLibCObjectFailed.

Without -target x86_64-linux-musl, but with -march and -mtune it builds fine too.

Expected Behavior

Expect that it can build MUSL when specifying -march and -mtune.

Actual Behavior

 #include <...> search starts here:
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libcxx/include-seses
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libcxxabi/include -target-feature
  /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libunwind/include
 -sgx/home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/include
  /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libc/include/x86_64-linux-musl
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libc/include/generic-musl-target-feature
  /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libc/include/x86_64-linux-any
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libc/include/any-linux-any
-shaEnd of search list.
 -target-feature -shstk -target-feature +slow-3ops-lea -target-feature -slow-incdec -target-feature -slow-lea clang -cc1 version 13.0.0-target-feature -slow-pmaddwd  based upon -target-feature LLVM 13.0.0-slow-pmulld default target x86_64-linux-musl -target-feature
 -slow-shld -target-feature -slow-two-mem-ops -target-feature -slow-unaligned-mem-16 -target-feature -slow-unaligned-mem-32 -target-feature clang -cc1 version 13.0.0-soft-float  based upon -target-feature LLVM 13.0.0+sse default target x86_64-linux-musl 
-target-feature +sse2 -target-feature +sse3 -target-feature +sse4.1 -target-feature +sse4.2 -target-feature -sse4a -target-feature -sse-unaligned-mem -target-feature +ssse3 -target-feature -tbm -target-feature -tsxldtrk -target-feature -uintr -target-feature -use-aa -target-feature -use-glm-div-sqrt-costs -target-feature -vaes -target-feature -vpclmulqdq -target-feature +vzeroupper -target-feature -waitpkg -target-feature -wbnoinvd -target-feature -widekl -target-feature +x87 -target-feature -xop -target-feature +xsave -target-feature -xsavec -target-feature -xsaveopt -target-feature -xsaves -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /home/ghuls/.cache/zig/tmp/f9dc32d71d0dbd62-args.o -x c++ args.cpp
#include "..." search starts here:
#include <...> search starts here:
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libcxx/include
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libcxxabi/include
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libunwind/include
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/include
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libc/include/x86_64-linux-musl
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libc/include/generic-musl
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libc/include/x86_64-linux-any
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libc/include/any-linux-any
End of search list.
#include "..." search starts here:
#include <...> search starts here:
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libcxx/include
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libcxxabi/include
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libunwind/include
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/include
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libc/include/x86_64-linux-musl
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libc/include/generic-musl
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libc/include/x86_64-linux-any
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libc/include/any-linux-any
End of search list.
clang -cc1 version 13.0.0 based upon LLVM 13.0.0 default target x86_64-linux-musl
#include "..." search starts here:
#include <...> search starts here:
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libcxx/include
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libcxxabi/include
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libunwind/include
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/include
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libc/include/x86_64-linux-musl
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libc/include/generic-musl
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libc/include/x86_64-linux-any
 /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libc/include/any-linux-any
End of search list.
ld.lld -r -error-limit=0 -m elf_x86_64 -static -o /home/ghuls/.cache/zig/o/27c823345484e3b3ea78df66f645b768/crtn.o /home/ghuls/.cache/zig/o/1441256e2e6cf71dd6e69a58ac9f6b64/crtn.o --allow-shlib-undefined
ld.lld -r -error-limit=0 -m elf_x86_64 -static -o /home/ghuls/.cache/zig/o/0133657b397893d03717dd9251ba0f36/crt1.o /home/ghuls/.cache/zig/o/58af92f975426555bd807269cba2b2cb/crt1.o --allow-shlib-undefined
ld.lld -r -error-limit=0 -m elf_x86_64 -static -o /home/ghuls/.cache/zig/o/843ea9d6c3479a0e5445a302f58dd13b/Scrt1.o /home/ghuls/.cache/zig/o/777869c1c89bcf17347059adb3ba1e2d/Scrt1.o --allow-shlib-undefined
ld.lld -r -error-limit=0 -m elf_x86_64 -static -o /home/ghuls/.cache/zig/o/1f0935cbb493b139e19cad3e5c9c54cf/rcrt1.o /home/ghuls/.cache/zig/o/02b26988fe2358630b0cfe5a4c7e7f31/rcrt1.o --allow-shlib-undefined
cbust.cpp:539:15: warning: 'bind2nd<std::plus<double>, double>' is deprecated [-Wdeprecated-declarations]
              bind2nd(plus<double>(), term));
              ^
/home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libcxx/include/__functional/binder2nd.h:45:1: note: 'bind2nd<std::plus<double>, double>' has been explicitly marked deprecated here
_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
^
/home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libcxx/include/__config:1002:39: note: expanded from macro '_LIBCPP_DEPRECATED_IN_CXX11'
#  define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
                                      ^
/home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libcxx/include/__config:991:48: note: expanded from macro '_LIBCPP_DEPRECATED'
#    define _LIBCPP_DEPRECATED __attribute__ ((deprecated))
                                               ^
Compile C Objects [1/5] Compile C Objects [472/1341] __fmodeflags.c... 1 warning generated.
error(compilation): /home/ghuls/ghuls/software/zig/zig-linux-x86_64-0.9.0-dev.1433+4a76523b9/lib/libc/musl/src/misc/getopt.c:1:1: unable to build C object: Unexpected
ar rcs /home/ghuls/.cache/zig/o/4602c2c80bc56bd7450641f036b3a76d/libunwind.a /home/ghuls/.cache/zig/o/c19e12079ac2f9e6d50cf771ace8accf/libunwind.o /home/ghuls/.cache/zig/o/e6726396b4910926289c6d451551dffa/Unwind-EHABI.o /home/ghuls/.cache/zig/o/71e0d156aa3d0a30828f151188b41f5e/Unwind-seh.o /home/ghuls/.cache/zig/o/a47444545f88eb812858cfdc8baa6237/UnwindLevel1.o /home/ghuls/.cache/zig/o/d76554dd7f92bbd75d7291b3aa0c3f67/UnwindLevel1-gcc-ext.o /home/ghuls/.cache/zig/o/c8115ef15305e1e0c39c62677e3483fe/Unwind-sjlj.o /home/ghuls/.cache/zig/o/241a805c7ee4cab938adf98573a0850d/UnwindRegistersRestore.o /home/ghuls/.cache/zig/o/041e3d11d5726a135ad10f2cc41c1b88/UnwindRegistersSave.o /home/ghuls/.cache/zig/o/caf3bc0ae1c259f71aed1d30739dd66f/gcc_personality_v0.o
ar rcs /home/ghuls/.cache/zig/o/f150bf2c9ebbffac921c21c933592ccc/libc++.a /home/ghuls/.cache/zig/o/a46f402b145a5a400ed4b523809d06a8/algorithm.o /home/ghuls/.cache/zig/o/796ff77e9c1cb874b562de45d44e5bad/any.o /home/ghuls/.cache/zig/o/a80544f1198b3cb7700cb77b1c8c26a7/atomic.o /home/ghuls/.cache/zig/o/719dab43c9f23fe47732d829c458f580/barrier.o /home/ghuls/.cache/zig/o/2717a613c413a9d2bbfaa4c893b0b6ab/bind.o /home/ghuls/.cache/zig/o/591c0727762c5fa464d0eee467acc8e9/charconv.o /home/ghuls/.cache/zig/o/7232f1bc90bc1e69833e34194efdc2b0/chrono.o /home/ghuls/.cache/zig/o/3920260609c773a39f11a8e6d2f7213d/condition_variable.o /home/ghuls/.cache/zig/o/8e7c5851c4c2966cce9bdd647371c4da/condition_variable_destructor.o /home/ghuls/.cache/zig/o/f1cd5705e200ef3b00cc34bbc18cdfce/debug.o /home/ghuls/.cache/zig/o/edda619795d49897abaf5d3d8bfab356/exception.o /home/ghuls/.cache/zig/o/20a0de0e6db4fa54641194c31baaa798/memory_resource.o /home/ghuls/.cache/zig/o/636a162cd82450b532248d755ed77a09/directory_iterator.o /home/ghuls/.cache/zig/o/089b6ee572bcfdd3533fedb205b72427/int128_builtins.o /home/ghuls/.cache/zig/o/c88f09ce81fbdf1bc73632374b9bdd52/operations.o /home/ghuls/.cache/zig/o/ac78bc11ecc91f3df7f14aaf42a36cb2/format.o /home/ghuls/.cache/zig/o/0f8ac39edb82fef0b2b198385d2aab7c/functional.o /home/ghuls/.cache/zig/o/694c7f5445debc25fc2ee482a65cbc9c/future.o /home/ghuls/.cache/zig/o/47c3f141f0bf5a4181015805474a7561/hash.o /home/ghuls/.cache/zig/o/147eff268432e8cc98a45873fbe5efc9/ios.o /home/ghuls/.cache/zig/o/c8b6dc438c62942e30d14309f6018b89/ios.instantiations.o /home/ghuls/.cache/zig/o/aca953c6cd7d9c79ec416a02cf341237/iostream.o /home/ghuls/.cache/zig/o/daf0fbc0c463ce3716e6e6c3e4b9bdc2/locale.o /home/ghuls/.cache/zig/o/d9f47bd300412c891f37f9d49217d23c/memory.o /home/ghuls/.cache/zig/o/d93fa55e780f6572c6d9c9393e0e518e/mutex.o /home/ghuls/.cache/zig/o/2ec95fad10a137c85b6e1c04a48c8709/mutex_destructor.o /home/ghuls/.cache/zig/o/eb80d35919d8dbb06f558a57b3e561f5/new.o /home/ghuls/.cache/zig/o/154e2af31feb08d7297c99ee204cfae3/optional.o /home/ghuls/.cache/zig/o/1e8553214ead8cc34ec9319c3ce544e2/random.o /home/ghuls/.cache/zig/o/208340c99561e6a320ea80eb34b83114/random_shuffle.o /home/ghuls/.cache/zig/o/8e1b29998a73c2775782de1afe8acac0/regex.o /home/ghuls/.cache/zig/o/6f3d25a2a4d6bb39ae79b2acc30490df/shared_mutex.o /home/ghuls/.cache/zig/o/7599a38c8e72d229efdc41b6da560bcc/stdexcept.o /home/ghuls/.cache/zig/o/7e23e8a2feb26b703c251714455a14fb/string.o /home/ghuls/.cache/zig/o/f3801c6e6cda324f85f980594d070e1b/strstream.o /home/ghuls/.cache/zig/o/6744ca6f1bd26a30ef9cdacec8b87cb9/system_error.o /home/ghuls/.cache/zig/o/f6f3756dc983f02c2c37731fba643fc4/thread.o /home/ghuls/.cache/zig/o/06e02d4b9f887dc978fc7c37121826d5/typeinfo.o /home/ghuls/.cache/zig/o/4f3451b7fdd9d3245b9011a5e0781046/utility.o /home/ghuls/.cache/zig/o/2b55f3cc7c9fd0e8ab1ad3341c52943f/valarray.o /home/ghuls/.cache/zig/o/5aad2423637ee10c09f6f97bf7859e48/variant.o /home/ghuls/.cache/zig/o/f9325648cf83d805f79f667f0341b3e1/vector.o
ar rcs /home/ghuls/.cache/zig/o/5a040390456ae1b06f228e5d31b7bac5/libc++abi.a /home/ghuls/.cache/zig/o/7fa330540d51e764e48f89f24df03603/abort_message.o /home/ghuls/.cache/zig/o/490ca43b6ed92e3d525d07af5012ce91/cxa_aux_runtime.o /home/ghuls/.cache/zig/o/2a2e1e59c1b7840622ca162a914d9463/cxa_default_handlers.o /home/ghuls/.cache/zig/o/6219185ce7b3e69a6fc0697cf2feec29/cxa_demangle.o /home/ghuls/.cache/zig/o/afd589b7b3a20198efc0502db040efa2/cxa_exception.o /home/ghuls/.cache/zig/o/db9b725af3b4ecf38a9712c13b9983fb/cxa_exception_storage.o /home/ghuls/.cache/zig/o/d713702aa6433f46a22f3838ef9c04d5/cxa_guard.o /home/ghuls/.cache/zig/o/ee247bf6ff60a70d15bff62740215e89/cxa_handlers.o /home/ghuls/.cache/zig/o/ecb10179901e131d58ee47f714fb775f/cxa_noexception.o /home/ghuls/.cache/zig/o/e76f7446d9cbae5f5ee24af9883b8c9f/cxa_personality.o /home/ghuls/.cache/zig/o/55134762ec451a03568e1b2f8265d36e/cxa_thread_atexit.o /home/ghuls/.cache/zig/o/f65aa814ef6e2657d25f0f449883e7bb/cxa_vector.o /home/ghuls/.cache/zig/o/27a18ea493822840d44387af16bc3d6a/cxa_virtual.o /home/ghuls/.cache/zig/o/4ec18e894ee9893d68343705101e3cab/fallback_malloc.o /home/ghuls/.cache/zig/o/a33d68ce8675630a071cd365492b145c/private_typeinfo.o /home/ghuls/.cache/zig/o/b56ed98fd8ac3416585b2b019395a95a/stdlib_exception.o /home/ghuls/.cache/zig/o/1566ba5a997d0d22cebb3c892118b5d6/stdlib_new_delete.o /home/ghuls/.cache/zig/o/90df360036a012c2a3d08336088f4d8b/stdlib_stdexcept.o /home/ghuls/.cache/zig/o/aa44189f99766297225b69a8f982ff47/stdlib_typeinfo.o
ar rcs /home/ghuls/.cache/zig/o/afd10a495eaf7eea54a25dabf7dbe3ee/libcompiler_rt.a /home/ghuls/.cache/zig/o/afd10a495eaf7eea54a25dabf7dbe3ee/compiler_rt.o
error: unable to build musl CRT file: BuildingLibCObjectFailed
@ghuls ghuls added the bug Observed behavior contradicts documented or intended behavior label Oct 20, 2021
@mikdusan
Copy link
Member

Can you check what the hard-limit (specifically NOT the soft-limit) of file descriptors for the process is?

@ghuls
Copy link
Author

ghuls commented Oct 20, 2021

$ ulimit -aH
core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 3092857
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 16384
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) unlimited
cpu time               (seconds, -t) unlimited
max user processes              (-u) 3092857
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

@andrewrk andrewrk added arch-x86_64 os-linux zig cc Zig as a drop-in C compiler feature labels Oct 20, 2021
@andrewrk andrewrk added this to the 0.10.0 milestone Oct 20, 2021
@mikdusan
Copy link
Member

Thanks. The reason I ask, I am able to get the same "error: unable to build musl CRT file: BuildingLibCObjectFailed" error message on linux by hard-limiting max open files to only 1024. Basically for musl, at this time, about 1350-1400 files are opened and locked during the build.

The limits that matter here are max open files, and file locks. We have code to bump max open files soft limit to hard limit, but maybe it's the file locks "soft limit" that is at issue.

Can you also provide:

  • linux distro, version, and which cpu architecture
  • and the soft limits... ulimit -a should do it

@ghuls
Copy link
Author

ghuls commented Oct 21, 2021

OS: CentOS 7
Architecture: x86_64

Soft limit is the same.

❯  ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 3092857
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 16384
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) unlimited
cpu time               (seconds, -t) unlimited
max user processes              (-u) 4096
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

I am not sure if that is the default hard limit on CentOS7. On the same HPC infrastructure this limit was 8192 in the past and we ran into a lot of problems running dask (as it starts a lot of processes and listens to a million ports) after which the limit was increased slightly.

Thanks for figuring out that it was a open file limit problem (didn't think about it as without -march it worked). Locally on my laptop it compiles without problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-x86_64 bug Observed behavior contradicts documented or intended behavior os-linux zig cc Zig as a drop-in C compiler feature
Projects
None yet
Development

No branches or pull requests

3 participants