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

Fix several issues during cross compiling #98328

Merged
merged 2 commits into from
Jul 9, 2022
Merged

Fix several issues during cross compiling #98328

merged 2 commits into from
Jul 9, 2022

Conversation

topjohnwu
Copy link
Contributor

  • When cross compiling LLVM on an arm64 macOS machine to x86_64, CMake will produce universal binaries by default, causing link errors. Explicitly set CMAKE_OSX_ARCHITECTURES to the one single target architecture so that the executables and libraries will be single architecture.
  • When cross compiling rustc with llvm.clang = true, CLANG_TABLEGEN has to be set to the host clang-tblgen executable to build clang.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 21, 2022
@topjohnwu
Copy link
Contributor Author

@jyn514 since you've reviewed my other PR, would you want to check this out too?

@jyn514
Copy link
Member

jyn514 commented Jun 23, 2022

When cross compiling LLVM on an arm64 macOS machine to x86_64, CMake will produce universal binaries by default, causing link errors.

Why does this cause link errors?

@jyn514 jyn514 added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Jun 23, 2022
src/bootstrap/native.rs Show resolved Hide resolved
src/bootstrap/native.rs Outdated Show resolved Hide resolved
@topjohnwu
Copy link
Contributor Author

I don't actually know why, but the linker will complain file too small for architecture. I think it's quite important that we do NOT build universal binaries for LLVM, as the rest of rustc does not.

@jyn514
Copy link
Member

jyn514 commented Jun 23, 2022

Hmm, ok, seems good to have LLVM's build be consistent with rustc's.

@jyn514
Copy link
Member

jyn514 commented Jun 23, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Jun 23, 2022

📌 Commit 91c7dd0 has been approved by jyn514

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 23, 2022
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jun 24, 2022
Fix several issues during cross compiling

- When cross compiling LLVM on an arm64 macOS machine to x86_64, CMake will produce universal binaries by default, causing link errors. Explicitly set `CMAKE_OSX_ARCHITECTURES` to the one single target architecture so that the executables and libraries will be single architecture.
- When cross compiling rustc with `llvm.clang = true`, `CLANG_TABLEGEN` has to be set to the host `clang-tblgen` executable to build clang.
@JohnTitor
Copy link
Member

Failed in rollup: #98442 (comment)
@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 24, 2022
@topjohnwu
Copy link
Contributor Author

topjohnwu commented Jun 24, 2022

@jyn514 turns out that LLVM_NM might still be required for cross compiling on MSVC. I added it back, hopefully this time all ci tests will pass 🙏

@JohnTitor I have pushed a new update to the PR

@topjohnwu topjohnwu requested a review from jyn514 June 24, 2022 12:06
@topjohnwu topjohnwu requested a review from jyn514 June 25, 2022 10:59
@jyn514
Copy link
Member

jyn514 commented Jun 25, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Jun 25, 2022

📌 Commit 7180afb has been approved by jyn514

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 25, 2022
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jun 26, 2022
Fix several issues during cross compiling

- When cross compiling LLVM on an arm64 macOS machine to x86_64, CMake will produce universal binaries by default, causing link errors. Explicitly set `CMAKE_OSX_ARCHITECTURES` to the one single target architecture so that the executables and libraries will be single architecture.
- When cross compiling rustc with `llvm.clang = true`, `CLANG_TABLEGEN` has to be set to the host `clang-tblgen` executable to build clang.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jun 29, 2022
Fix several issues during cross compiling

- When cross compiling LLVM on an arm64 macOS machine to x86_64, CMake will produce universal binaries by default, causing link errors. Explicitly set `CMAKE_OSX_ARCHITECTURES` to the one single target architecture so that the executables and libraries will be single architecture.
- When cross compiling rustc with `llvm.clang = true`, `CLANG_TABLEGEN` has to be set to the host `clang-tblgen` executable to build clang.
When cross compiling LLVM on an arm64 machine to x86_64, CMake will
produce universal binaries by default, causing link errors. Explicitly
set CMAKE_OSX_ARCHITECTURES to the one single target architecture.
When cross compiling rustc with `llvm.clang = true`, CLANG_TABLEGEN
has to be set to the host clang-tblgen executable to build clang.
@topjohnwu
Copy link
Contributor Author

topjohnwu commented Jul 4, 2022

@jyn514 hello, I have added a few changes to my PR

  • Only check the existence of clang-tblgen if not during a dry run
  • Add a fix to the libLLVM.dylib symlink workaround. More details in the commit message

r? @jyn514

@jyn514
Copy link
Member

jyn514 commented Jul 4, 2022

@bors r-

@topjohnwu can we please merge the existing changes before you add more? You can make a new PR if you want to get a review before this one is merged.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 4, 2022
@topjohnwu
Copy link
Contributor Author

@jyn514 sure, I'll split the 3rd commit into its own PR

@jyn514
Copy link
Member

jyn514 commented Jul 4, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Jul 4, 2022

📌 Commit 600026a has been approved by jyn514

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 4, 2022
@bors
Copy link
Contributor

bors commented Jul 9, 2022

⌛ Testing commit 600026a with merge 73443a0...

@alex
Copy link
Member

alex commented Jul 9, 2022

@jyn514 fwiw the source of those errors is #55235

@bors
Copy link
Contributor

bors commented Jul 9, 2022

☀️ Test successful - checks-actions
Approved by: jyn514
Pushing 73443a0 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 9, 2022
@bors bors merged commit 73443a0 into rust-lang:master Jul 9, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jul 9, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (73443a0): comparison url.

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results
  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: 🎉 relevant improvements found
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
N/A N/A 0
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
-4.6% -8.7% 4
All 😿🎉 (primary) N/A N/A 0

Cycles

Results
  • Primary benchmarks: mixed results
  • Secondary benchmarks: 🎉 relevant improvement found
mean1 max count2
Regressions 😿
(primary)
3.5% 3.7% 2
Regressions 😿
(secondary)
N/A N/A 0
Improvements 🎉
(primary)
-7.1% -7.1% 1
Improvements 🎉
(secondary)
-2.2% -2.2% 1
All 😿🎉 (primary) -0.1% -7.1% 3

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

Footnotes

  1. the arithmetic mean of the percent change 2

  2. number of relevant changes 2

@topjohnwu topjohnwu deleted the fix_cross branch July 12, 2022 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants