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

Improve zigcc support #5921

Merged
merged 7 commits into from
Dec 3, 2024
Merged

Improve zigcc support #5921

merged 7 commits into from
Dec 3, 2024

Conversation

Redbeanw44602
Copy link
Contributor

@Redbeanw44602 Redbeanw44602 commented Dec 2, 2024

  • fix ar
  • fix cmake build (add wrapper)

#5610

* fix ar, wrong definition
* add ranlib & objcopy
* remove non-standard environment variable ZC
@waruqi
Copy link
Member

waruqi commented Dec 3, 2024

it does not work on macOS. but it works for dev branch

/var/folders/32/w9cz0y_14hs19lkbs6v6_fm80000gn/T/.xmake501/241203/zigcc/cc -c -Qunused-argument
s -target x86_64-apple-macos14.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms
/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -fvisibility=hidden -DNDEBUG -o build/.objs/test
/macosx/x86_64/release/src/main.c.o src/main.c
checking for flags (-MMD -MF) ... ok
checking for flags (-fdiagnostics-color=always) ... no
checking for flags (-fcolor-diagnostics) ... ok
checking for flags (-Wno-gnu-line-marker -Werror) ... no
error: error: unable to parse target query 'x86_64-apple-macos14.0': UnknownOperatingSystem

@Redbeanw44602
Copy link
Contributor Author

it does not work on macOS. but it works for dev branch

/var/folders/32/w9cz0y_14hs19lkbs6v6_fm80000gn/T/.xmake501/241203/zigcc/cc -c -Qunused-argument
s -target x86_64-apple-macos14.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms
/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -fvisibility=hidden -DNDEBUG -o build/.objs/test
/macosx/x86_64/release/src/main.c.o src/main.c
checking for flags (-MMD -MF) ... ok
checking for flags (-fdiagnostics-color=always) ... no
checking for flags (-fcolor-diagnostics) ... ok
checking for flags (-Wno-gnu-line-marker -Werror) ... no
error: error: unable to parse target query 'x86_64-apple-macos14.0': UnknownOperatingSystem

Sorry I don't have a macos device, according to Nuitka/Nuitka#2756, maybe apple- is unnecessary?

@Redbeanw44602
Copy link
Contributor Author

Redbeanw44602 commented Dec 3, 2024

$ zig c++ -target x86_64-macos simple.cpp
$ file a.out
a.out: Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|WEAK_DEFINES|BINDS_TO_WEAK|NO_REEXPORTED_DYLIBS|PIE>

It seems that the correct target should be x86_64-macos(-none).

@waruqi
Copy link
Member

waruqi commented Dec 3, 2024

$ zig c++ -target x86_64-macos simple.cpp
$ file a.out
a.out: Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|WEAK_DEFINES|BINDS_TO_WEAK|NO_REEXPORTED_DYLIBS|PIE>

It seems that the correct target should be x86_64-macos(-none).

if I do not apply this patch, it will use -target x86_64-macos on dev branch.

@Redbeanw44602
Copy link
Contributor Author

Redbeanw44602 commented Dec 3, 2024

if I do not apply this patch, it will use -target x86_64-macos on dev branch.

I see, I'm checking what went wrong... it's a bit mysterious

@waruqi
Copy link
Member

waruqi commented Dec 3, 2024

it will add target flags for zig cc/c++

toolchain:add("zig_cc.asflags", "-target", target)
toolchain:add("zig_cc.cxflags", "-target", target)
toolchain:add("zig_cc.shflags", "-target", target)
toolchain:add("zig_cc.ldflags", "-target", target)
toolchain:add("zig_cxx.cxflags", "-target", target)
toolchain:add("zig_cxx.shflags", "-target", target)
toolchain:add("zig_cxx.ldflags", "-target", target)

but its name has been rename to cc , so these flags will be ignored.

@Redbeanw44602
Copy link
Contributor Author

I didn't see any renames happening in the diff, and if that's the problem, it shouldn't just affect macOS (it works on my linux🤔)

@waruqi
Copy link
Member

waruqi commented Dec 3, 2024

I didn't see any renames happening in the diff, and if that's the problem, it shouldn't just affect macOS (it works on my linux🤔)

if you rename to cc/c++, it will use tools/cc.lua instead of tools/zig_cc.lua, zig_cc.lua will do some thing for zig cc

@waruqi waruqi added this to the v2.9.7 milestone Dec 3, 2024
@waruqi waruqi merged commit 6c09c81 into xmake-io:dev Dec 3, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants