Skip to content

zig cc: unsupported darwin linker args #4841

@opti-mix

Description

@opti-mix

Thanks a lot for adding zig cc and zig c++ functionality. It is really useful.

I tried to use zig c++ instead of the standard LLVM toolchain for one of my projects. I build it on MacOS. In general, it mostly works, but I've discovered the following issues:

  1. There is a number of flags passed to the linker using -Wl,my_linker_option. They are important for proper linking of the project. But some of them are not supported yet.
warning: unsupported linker arg: -search_paths_first
warning: unsupported linker arg: -headerpad_max_install_names
warning: unsupported linker arg: -force_load
warning: unsupported linker arg: -force_load
  1. If I configure my CMake-based project to use make and then run make, it seems to work fine as long as make is using just a single thread. But if I use e.g. make -j 2 I start seeing some issues:
zig -c test.cpp -std=c++14 -ffast-math -fno-finite-math-only -g -I/path/to/include -emit-llvm -O0 -o test.o
Invalid argument: -c

It seems as if there is a race condition somewhere. As you can seen in zig's command line it misses c++ after zig somehow.

  1. If I configure my CMake-based project to use ninja and then run ninja, I see issues with dependency tracking supported by clang. Specifically, there seems to be an issue with handling of -MF flags (see below). Same project can be build just fine if I use the vanilla LLVM toolchain.
zig: error: no such file or directory: 'test.cpp.o.d'

The following command failed when running ninja:
zig clang -c -MD -MV -MF zig-cache/tmp/eamNMvLXEZYC-test.o.d  -MD -MT -MF test.cpp.o.d -o zig-cache/tmp/eamNMvLXEZYC-test.o test.cpp

It would be nice if these issues could be resolved.

Please let me know if I can provide any additional information that would allow to fix these issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    os-macosupstreamAn issue with a third party project that Zig uses.zig ccZig as a drop-in C compiler feature

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions