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

gclang drops -mllvm argument #52

Closed
pietroborrello opened this issue Jun 29, 2021 · 3 comments
Closed

gclang drops -mllvm argument #52

pietroborrello opened this issue Jun 29, 2021 · 3 comments

Comments

@pietroborrello
Copy link

It seems that gclang mishandles the -mllvm compilation flags. For example passing -mllvm -stack-alignment=16.

Environment

  • gllvm version 1.3.0
  • go version go1.16.5
  • llvm version 10

To reproduce:

main.c:

int main(int argc, char ** argv) {
    return 0;
}
$ WLLVM_OUTPUT_LEVEL="DEBUG" gclang -mllvm -stack-alignment=16 main.c             
INFO:Entering CC [-mllvm -stack-alignment=16 main.c]
DEBUG:Compile using parsed arguments:
InputList:         [-mllvm -stack-alignment=16 main.c]
InputFiles:        [main.c]
ObjectFiles:       []
OutputFilename:    
CompileArgs:       [-mllvm]
LinkArgs:          []
ForbiddenFlags:    []
IsVerbose:         false
IsDependencyOnly:  false
IsPreprocessOnly:  false
IsAssembleOnly:    false
IsAssembly:        false
IsCompileOnly:     false
IsEmitLLVM:        false
IsLTO:             false
IsPrintOnly:       false

DEBUG:buildObjectFile: [-mllvm main.c -c -o .main.c.o]
DEBUG:Calling execCmd(clang, [-mllvm -stack-alignment=16 main.c])
clang: error: no input files
DEBUG:execCmd: clang [-mllvm main.c -c -o .main.c.o] had exitCode 1
DEBUG:execCmd: error was exit status 1
ERROR:Failed to build object file for main.c because: exit status 1
DEBUG:execCmd: clang [-mllvm -stack-alignment=16 main.c] had exitCode 0
clang (LLVM option parsing): Unknown command line argument '-emit-llvm'.  Try: 'clang (LLVM option parsing) --help'
clang (LLVM option parsing): Did you mean '  --mno-hvx'?
DEBUG:execCmd: clang [-mllvm -emit-llvm -c main.c -o .main.c.o.bc] had exitCode 1
DEBUG:execCmd: error was exit status 1
ERROR:Failed to build bitcode file for main.c because: exit status 1
DEBUG:attachBitcodePathToObject recognized .o as something it can inject into.
objcopy: '.main.c.o': No such file
DEBUG:execCmd: objcopy [--add-section .llvm_bc=/tmp/gllvm172431081 .main.c.o] had exitCode 1
DEBUG:execCmd: error was exit status 1
WARNING:attachBitcodePathToObject: objcopy [--add-section .llvm_bc=/tmp/gllvm172431081 .main.c.o] failed because exit status 1
clang: error: no such file or directory: '.main.c.o'
clang: error: no input files
DEBUG:execCmd: clang [.main.c.o -o a.out] had exitCode 1
DEBUG:execCmd: error was exit status 1
ERROR:clang [.main.c.o -o a.out] failed to link: exit status 1.
DEBUG:Calling [gclang -mllvm -stack-alignment=16 main.c] returned 0

It fails to forward the -mllvm argument in some of the steps, like with -mllvm -emit-llvm -c main.c -o .main.c.o.bc, where -emit-llvm gets parsed by clang as the option for -mllvm making the build fail.

@ianamason
Copy link
Member

Thanks, there was a typo...

d01ecad

@pietroborrello
Copy link
Author

Thank you for the fast reply and fix!

@ianamason
Copy link
Member

As opposed to #48 which I have not (yet) forgotten about :-0

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