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 clang -emit-llvm does not work as intended with assembly and is not available in compile step #14977

Closed
RossComputerGuy opened this issue Mar 17, 2023 · 3 comments

Comments

@RossComputerGuy
Copy link
Contributor

Zig Version

0.11.0-dev.1969+d525ecb52

Steps to Reproduce and Observed Behavior

Try compiling src/x86/unix64.S with zig clang in libffi, I have it integrated into my project and I discovered this error:

/home/ross/ExpidusOS/neutron/vendor/libs/libffi/src/x86/unix64.S:596:14: error: invalid variant 'rel'
 .long .LUW0@rel
             ^
/home/ross/ExpidusOS/neutron/vendor/libs/libffi/src/x86/unix64.S:615:14: error: invalid variant 'rel'
 .long .LUW5@rel
             ^
/home/ross/ExpidusOS/neutron/vendor/libs/libffi/src/x86/unix64.S:628:14: error: invalid variant 'rel'
 .long .LUW8@rel
             ^
/home/ross/ExpidusOS/neutron/vendor/libs/libffi/src/x86/unix64.S:642:15: error: invalid variant 'rel'
 .long .LUW12@rel
              ^
/home/ross/ExpidusOS/neutron/vendor/libs/libffi/src/x86/unix64.S:655:15: error: invalid variant 'rel'
 .long .LUW15@rel

I did some digging and -emit-llvm should fix that. I naturally tried emit_llvm_ir and emit_llvm_br in std.Build.CompileStep on one made from std.Build.addAssembly(). This however, does not solve this error. I noticed emit_llvm_ir and emit_llvm_br did not add the argument so I ran the command that was outputted with zig build --verbose-cc and it worked just fine. So we've got 2 problems here:

  1. Currently, std.Build does not have a way to pass emit-llvm to zig clang
  2. zig clang's -emit-llvm argument does not function the same as clang's -emit-llvm

Expected Behavior

What we should have is:

  1. std.Build.CompileStep should pass -emit-llvm, probably with a new EmitOption called emit_llvm, which is passed to zig clang
  2. zig clang -emit-llvm should be functioning the same as clang -emit-llvm which would fix the assembly error
@RossComputerGuy RossComputerGuy added the bug Observed behavior contradicts documented or intended behavior label Mar 17, 2023
@andrewrk
Copy link
Member

Related: #14971

@RossComputerGuy
Copy link
Contributor Author

This problem is kinda solved in libffi with defining HAVE_AS_X86_PCREL in the config file but on x86 (not x86_64), I run into #7935

@andrewrk andrewrk removed the bug Observed behavior contradicts documented or intended behavior label Apr 10, 2023
@andrewrk
Copy link
Member

andrewrk commented Apr 10, 2023

zig clang is not a supported feature. Are you intending to use zig cc instead?

Closing since zig clang is unsupported. Will re-open if further information is provided.

@andrewrk andrewrk closed this as not planned Won't fix, can't repro, duplicate, stale Apr 10, 2023
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

No branches or pull requests

2 participants