-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
rust: update to 1.70.0 #17406
rust: update to 1.70.0 #17406
Conversation
4b7ff67
to
6bcc45c
Compare
clang64 fails with: error: Dlltool could not create import library: OVERVIEW: llvm-dlltool
USAGE: llvm-dlltool [options] file...
OPTIONS:
-D <value> Specify the input DLL Name
-d <value> Input .def File
-f <value> Assembler Flags
-k Kill @n Symbol from export
-l <value> Generate an import lib
-m <value> Set target machine
-S <value> Assembler
TARGETS: i386, i386:x86-64, arm, arm64
\n
error: could not compile `windows` due to previous error On clang, $ dlltool -V
OVERVIEW: llvm-dlltool
USAGE: llvm-dlltool [options] file...
OPTIONS:
-D <value> Specify the input DLL Name
-d <value> Input .def File
-f <value> Assembler Flags
-k Kill @n Symbol from export
-l <value> Generate an import lib
-m <value> Set target machine
-S <value> Assembler
TARGETS: i386, i386:x86-64, arm, arm64 While on mingw $ dlltool -V
GNU C:\msys64\mingw64\bin\dlltool.exe (GNU Binutils) 2.40
Copyright (C) 2023 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty. Is the clang behavior new ? |
Note that the build failure comes from the bootstrap compiler (the stage 0 compiler). |
$ pkgfile dlltool.exe
mingw64/mingw-w64-x86_64-binutils
clang64/mingw-w64-clang-x86_64-llvm
msys/binutils
msys/mingw-w64-cross-binutils |
also it would be better to have llvm-libs as dependency like arch does |
oops, these was about binutils for gcc toolchain... I think that this commit has really changed things |
No, CLANG* dlltool has always been llvm-dlltool, GNU binutils is not used there. I'm guessing something in rust (or a crate pulled in) is now trying to use a dlltool option that llvm-dlltool doesn't implement. As you can see GNU dlltool has a lot more options, most of which are not all that useful anymore. Wish llvm-dlltool would include what unknown options it was given in the error, rather than just the generic usage information. CC @mstorsjo would probably be interested too |
I noticed If it were, I could see where it could get confused, because of the hacks that are still present to make CLANG64 use x86_64-pc-windows-gnu instead of -gnullvm. Also, the lack of any i686-pc-windows-gnullvm handling means that CLANG32 must still use i686-pc-windows-gnu. @mati865 I'm guessing around https://github.com/microsoft/windows-rs/blob/0b333d3d9b15bbf8193ded2d776a666137a372f5/crates/tools/gnu/src/main.rs#L110 is where it would start passing unknown args to dlltool. |
Rust does use options that are not advertised by llvm-dlltool. For example here : https://github.com/rust-lang/rust/blob/794249d768a4f112519f22502ade032dc03b9fde/compiler/rustc_codegen_llvm/src/back/archive.rs#L201. But it is not new, so, yes, maybe the windows crate has started to use it. |
That probably makes more sense... The is_mingw_gnu_toolchain function looks specifically for abi being empty (ie, not -gnullvm), so maybe the hack patch that makes CLANG32/64 work as -gnu needs to patch that function to be false there? Or it's about time to switch to -gnullvm |
happily CLANGARM64 build succeeded on this version |
It seems to be a little of both: it is trying to produce an import library for kernel32 while building the windows crate, but the windows crate itself doesn't seem to be calling dlltool. I'm thinking it must be the raw-dylib thing causing that rust code you linked to to be invoked to create an import library? Unfortunately, the bootstrap stage0 compiler downloaded is trying to call dlltool, so just patching that code does not work (the compiler with that patch doesn't exist yet). I made a python wrapper script that filtered out the "unknown" options I just tried not filtering out |
I think something like this patch needs to be added to --- rustc-1.70.0-src/compiler/rustc_codegen_llvm/src/common.rs.orig 2023-06-02 17:34:23.626069500 -0700
+++ rustc-1.70.0-src/compiler/rustc_codegen_llvm/src/common.rs 2023-06-02 17:35:00.023376400 -0700
@@ -382,7 +382,7 @@
}
pub(crate) fn is_mingw_gnu_toolchain(target: &Target) -> bool {
- target.vendor == "pc" && target.os == "windows" && target.env == "gnu" && target.abi.is_empty()
+ false && target.vendor == "pc" && target.os == "windows" && target.env == "gnu" && target.abi.is_empty()
}
pub(crate) fn i686_decorated_name( Unfortunately due to bootstrapping, this is not sufficient. I see 3 ways around this:
|
I'll give it a shot next week. |
llvm-dlltool already ignores a couple of options: https://github.com/llvm/llvm-project/blob/0a168131b4f420d9f561926c643c143c84c97535/llvm/lib/ToolDrivers/llvm-dlltool/Options.td#L19 But ignoring more is kind of scary... as they do things. |
I've got a build running now of 1.70.0 with bootstrapping=no with a patched 1.69.0 installed, on CLANG64.
This is why I mentioned @mstorsjo on this... he'd know best what needs to happen with llvm-dlltool. I think For reference, here's an example of args to dlltool logged by my python script:
And my python script: $ ls /foo
dlltool.exe dlltool-script.py
$ cat /foo/dlltool-script.py #!c:/msys64/clang64/bin/python
import subprocess
import sys
with open("C:/msys64/tmp/dlltool.log", "a") as f:
print(repr(sys.argv[1:]), file=f)
i = 1
args = ["C:/msys64/clang64/bin/dlltool.exe"]
while i < len(sys.argv):
if sys.argv[i] == "--temp-prefix":
i += 1
#elif False and sys.argv[i] == "--no-leading-underscore":
# pass
else:
args.append(sys.argv[i])
i += 1
sys.exit(subprocess.run(args=args).returncode) |
I am also in the process of building 1.70.0 with a patched 1.69.0. Seems good... I have branches ready that I'll push tomorrow. |
Another cleanup that can be done for _bootstrapping=no: mkdir -p "${srcdir}/${MSYSTEM}" && cd "${srcdir}/${MSYSTEM}"
# The ultimate hack to let the bootstrap compiler use libgcc* libs
- if [[ $MINGW_PACKAGE_PREFIX == *-clang-i686 || $MINGW_PACKAGE_PREFIX == *-clang-x86_64 ]]; then
+ if [[ $_bootstrapping != "no" ]] && [[ $MINGW_PACKAGE_PREFIX == *-clang-i686 || $MINGW_PACKAGE_PREFIX == *-clang-x86_64 ]]; then
export GCC_LIBS_HACK="$(cygpath -am build/missing-libs-hack)"
mkdir -p "${GCC_LIBS_HACK}"
cp "$(cygpath -u $(clang -print-libgcc-file-name))" "${GCC_LIBS_HACK}/libgcc.a" |
Yes, that's true,
Hmm, if I try to call llvm-dlltool with that option, it does error out similarly to |
It seems that it just doesn't like the fact that the unknown |
Oh, right, that explains it! |
I confirm that approach 3. works: $ rustc --version
rustc 1.70.0 (90c541806 2023-05-31) (Rev1, Built by MSYS2 project) |
I have done this for CLANG64 and CLANG32.
Next, I intend to try this with CLANG32, because I am curious if the ignoring of the |
I only tested CLANG64, so good to know. The stuff I pushed is for both CLANG64 and CLANG32 though. |
This failed with a bunch of undefined dllimport symbol linker errors, such as:
So I guess the |
Btw, Rust 1.69.0 does not use the |
Sorry for radio silence, I've had company trip so the timing was a bit unfortunate. There are 2 ways Rust can create import libraries: using LLVM API or dlltool. I can look at it and do some testing tomorrow. |
Oh, jeremyd2019 has already found it. I think all 3 options would be viable with 1. slightly risky and 3. being possibly hard. |
@mati865 Option 3. is in the work. @jeremyd2019 has validated that it works for CLANG64 and CLANG32. I validated that it works for CLANG64. There is a in progress PR for patching 1.69.0 but the MINGW32 build fails/times out (see #17433). |
Based on subsequest testing I think option 3 is probably the only one that would work for CLANG32, option 1 would also require implementing the
Also, there is no i686-pc-windows-gnullvm, and I noticed in some crates when they added support for -gnullvm that they didn't seem to make the logical conclusion that there could be in the future |
Option 3. implies that we have to keep bootstrapping=no for clang and can't revert to yes anymore (unless something is fixed upstream). |
Implementing that option should be fairly straightforward, I think. I can give it a shot hopefully within a few days, if not sooner. |
That would be my fault, it was failing back when Rust was using LLVM 15 and I haven't submitted it after LLVM 16 was released. |
set _bootstrapping=no for MINGW32 see msys2#17406
As a reminder, though this PR may pass CI once 1.69.0-2 is in staging, it should not be merged until that version is uploaded to the repos, because autobuild will remove the staging version before trying to build a new version. |
Once 1.69.0-2 is officially available, I'll rebase and push this branch again. |
set _bootstrapping=no for clang* remove patch 0012-revert-install-llvm-tools.patch
I re-ran the CI on afde6f4 once 1.69.0-2 was in staging, and all MSYSTEMs passed. |
CI is green... |
That would help us in the future. |
Those patches were applied upstream, and are now backported in our llvm 16.0.5-1 packages |
I'll make sure to revert to bootstrap=yes when Rust 1.71.0 comes out, |
but why can't we do this now? |
Just replace |
What would be the point ? |
yes, let's give it a try |
No description provided.