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

Support cross-compilation via -target ... option #72

Merged
merged 3 commits into from
Aug 25, 2023

Conversation

umbertov
Copy link

Hi, as discussed in the issue #71 , I propose the following two changes:

  • Support the -target ARCHITECTURE in shared/parser.go
  • Default to llvm-objcopy because that's what comes with the LLVM toolchain, which supports any target. This changes the pre-existing default of objcopy from the GNU toolchain, which only supports the native compilation target (i.e. x86 on x86 machines, arm on arm machines).

If someone still wishes to use GNU objcopy, they can still use it by setting the GLLVM_OBJCOPY=objcopy environment variable for native targets, or the prefixed version for cross-compilation toolchains, e.g. GLLVM_OBJCOPY=aarch64-linux-gnu-objcopy for arm64.

@ianamason
Copy link
Member

Got any idea why the tests are failing?

@ianamason
Copy link
Member

I think objcopy should remain the default, ONLY because it is a good idea to maintain backward compatibility. Then you won't need to alter the documentation. Maybe also this is the cause of the test failure?

@umbertov
Copy link
Author

umbertov commented Aug 23, 2023 via email

@umbertov
Copy link
Author

Hi, I just implemented what you mentioned in the issue #71:

  • removed the llvm-objcopy default (dirty old force push method)
  • added the ^--target=.*$ pattern to support --target=ARCH flag in addition to -target ARCH
  • wrote a bunch of lines in the README.md to document the use of GLLVM_OBJCOPY when cross-compiling

Let me know if everything looks fine to you, and thanks for all your help along the way!

@ianamason
Copy link
Member

Thanks @umbertov I’ll merge it in when I get home. Thanks again.

@umbertov
Copy link
Author

hey @ianamason github noticed me that a test is failing; specifically, Test_file_type.

I tried reproducing it on my machine with go test -v ./tests, and it worked on my machine ™️

gllvm_cross git:(master-rename) go test -v ./tests

=== RUN   Test_basic_functionality
Loading '/home/umberto/dev/gllvm_cross/tests/.helloworld.c.o.bc'
Linking in '/home/umberto/dev/gllvm_cross/tests/.helloworld.c.o.bc'
Writing bitcode...
Bitcode file extracted to: ../data/hello.bc.
--- PASS: Test_basic_functionality (0.27s)
=== RUN   Test_more_functionality
Loading '/home/umberto/dev/gllvm_cross/data/.bhello.o.bc'
Linking in '/home/umberto/dev/gllvm_cross/data/.bhello.o.bc'
Writing bitcode...
Bitcode file extracted to: ../data/bhello.bc.
--- PASS: Test_more_functionality (0.05s)
=== RUN   Test_obscure_functionality
Loading '/home/umberto/dev/gllvm_cross/data/.bhello.notanextensionthatwerecognize.bc'
Linking in '/home/umberto/dev/gllvm_cross/data/.bhello.notanextensionthatwerecognize.bc'
Writing bitcode...
Bitcode file extracted to: ../data/bhello.bc.
--- PASS: Test_obscure_functionality (0.08s)
=== RUN   Test_file_type
--- PASS: Test_file_type (0.00s)
=== RUN   Test_env_and_args
--- PASS: Test_env_and_args (0.01s)
=== RUN   Test_parsing
--- PASS: Test_parsing (0.02s)
PASS
ok  	github.com/umbertov/gllvm/tests	0.427s

@ianamason
Copy link
Member

I'll look into it once I have merged it in. The current, premerge, fails on my M1 so I guess it is unrelated.

@ianamason ianamason merged commit 3c946a9 into SRI-CSL:master Aug 25, 2023
1 check failed
@ianamason
Copy link
Member

Yes it succeeds on my M1 too, so it is probably just bitrot with the test. I'll look into it.

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.

3 participants