From 47b7211e6fc1981eb755dd68ee332f4463b06444 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 20 Dec 2022 16:02:15 +0100 Subject: [PATCH 1/4] Don't explicitly set C++ standard for lld LLVM does this itself since 606cb8548a1b7763e0c8489c5efe66803a7ede72, and 14 is no longer the correct standard when building lld 16, causing build failures. --- src/bootstrap/native.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index f6c453ebe107b..8052bde6024ee 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -886,10 +886,6 @@ impl Step for Lld { ); } - // Explicitly set C++ standard, because upstream doesn't do so - // for standalone builds. - cfg.define("CMAKE_CXX_STANDARD", "14"); - cfg.build(); t!(File::create(&done_stamp)); From 921981884706a6bb9b707b3fb74d01a764b90bee Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 20 Dec 2022 17:07:04 +0100 Subject: [PATCH 2/4] Use LLVM_CMAKE_DIR for lld build LLVM_CONFIG_PATH is no longer supported. --- src/bootstrap/native.rs | 47 ++++++----------------------------------- 1 file changed, 7 insertions(+), 40 deletions(-) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 8052bde6024ee..fee06df64a75f 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -804,6 +804,12 @@ impl Step for Lld { let target = self.target; let llvm_config = builder.ensure(Llvm { target: self.target }); + let mut llvm_cmake_dir = llvm_config; + llvm_cmake_dir.pop(); + llvm_cmake_dir.pop(); + llvm_cmake_dir.push("lib"); + llvm_cmake_dir.push("cmake"); + llvm_cmake_dir.push("llvm"); let out_dir = builder.lld_out(target); let done_stamp = out_dir.join("lld-finished-building"); @@ -834,22 +840,6 @@ impl Step for Lld { configure_cmake(builder, target, &mut cfg, true, ldflags); configure_llvm(builder, target, &mut cfg); - // This is an awful, awful hack. Discovered when we migrated to using - // clang-cl to compile LLVM/LLD it turns out that LLD, when built out of - // tree, will execute `llvm-config --cmakedir` and then tell CMake about - // that directory for later processing. Unfortunately if this path has - // forward slashes in it (which it basically always does on Windows) - // then CMake will hit a syntax error later on as... something isn't - // escaped it seems? - // - // Instead of attempting to fix this problem in upstream CMake and/or - // LLVM/LLD we just hack around it here. This thin wrapper will take the - // output from llvm-config and replace all instances of `\` with `/` to - // ensure we don't hit the same bugs with escaping. It means that you - // can't build on a system where your paths require `\` on Windows, but - // there's probably a lot of reasons you can't do that other than this. - let llvm_config_shim = env::current_exe().unwrap().with_file_name("llvm-config-wrapper"); - // Re-use the same flags as llvm to control the level of debug information // generated for lld. let profile = match (builder.config.llvm_optimize, builder.config.llvm_release_debuginfo) { @@ -860,32 +850,9 @@ impl Step for Lld { cfg.out_dir(&out_dir) .profile(profile) - .env("LLVM_CONFIG_REAL", &llvm_config) - .define("LLVM_CONFIG_PATH", llvm_config_shim) + .define("LLVM_CMAKE_DIR", llvm_cmake_dir) .define("LLVM_INCLUDE_TESTS", "OFF"); - // While we're using this horrible workaround to shim the execution of - // llvm-config, let's just pile on more. I can't seem to figure out how - // to build LLD as a standalone project and also cross-compile it at the - // same time. It wants a natively executable `llvm-config` to learn - // about LLVM, but then it learns about all the host configuration of - // LLVM and tries to link to host LLVM libraries. - // - // To work around that we tell our shim to replace anything with the - // build target with the actual target instead. This'll break parts of - // LLD though which try to execute host tools, such as llvm-tblgen, so - // we specifically tell it where to find those. This is likely super - // brittle and will break over time. If anyone knows better how to - // cross-compile LLD it would be much appreciated to fix this! - if target != builder.config.build { - cfg.env("LLVM_CONFIG_SHIM_REPLACE", &builder.config.build.triple) - .env("LLVM_CONFIG_SHIM_REPLACE_WITH", &target.triple) - .define( - "LLVM_TABLEGEN_EXE", - llvm_config.with_file_name("llvm-tblgen").with_extension(EXE_EXTENSION), - ); - } - cfg.build(); t!(File::create(&done_stamp)); From 2c8117139168b1cc8a9048b703cab0634d0d9e1c Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 20 Dec 2022 15:05:09 +0100 Subject: [PATCH 3/4] update submodule --- .gitmodules | 4 ++-- src/llvm-project | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 4011a6fa6b95b..03cd23329592a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -27,8 +27,8 @@ url = https://github.com/rust-lang/edition-guide.git [submodule "src/llvm-project"] path = src/llvm-project - url = https://github.com/rust-lang/llvm-project.git - branch = rustc/15.0-2022-12-07 + url = https://github.com/nikic/llvm-project.git + branch = rustc/rust-func-spec [submodule "src/doc/embedded-book"] path = src/doc/embedded-book url = https://github.com/rust-embedded/book.git diff --git a/src/llvm-project b/src/llvm-project index 3dfd4d93fa013..762fefed1d790 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 3dfd4d93fa013e1c0578d3ceac5c8f4ebba4b6ec +Subproject commit 762fefed1d7908331349f17c561c1c281ba393d8 From 228430a0ef3125c8056bddb91227f1433c88571c Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 21 Dec 2022 15:30:30 +0100 Subject: [PATCH 4/4] baseline --- src/llvm-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llvm-project b/src/llvm-project index 762fefed1d790..eca99c31e164b 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 762fefed1d7908331349f17c561c1c281ba393d8 +Subproject commit eca99c31e164b8de738ebaade6871490abb063e0