-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
mingw: Use aro instead of clang for preprocessing import libs #17771
Conversation
68f16db
to
fb0fb5b
Compare
I suggest to put a check for |
Is there a way to test this locally if I don't have access to a windows machine? I don't want to spam the CI with attempts, since I'm not totally sure where the check should go. It seems like the function is being used, since we're hitting that panic - does that mean that if |
Yes, here is a way to test it:
If you get the compile error, it's incorrectly including aro in the build. The check goes at the top of if (build_options.only_core_functionality) @panic("building import libs not included in core functionality"); |
Oops, I gave you some bad advice. It should be checking We don't want the logic to be part of zig1.wasm, however we do want the logic to be part of zig2.c. The use case for |
Ok, if I add that I assume it means it's also safe for me to remove the |
} | ||
|
||
const lib_final_path = try comp.global_cache_directory.join(comp.gpa, &[_][]const u8{ | ||
"o", &digest, final_lib_basename, | ||
}); | ||
errdefer comp.gpa.free(lib_final_path); | ||
|
||
if (!build_options.have_llvm) return error.ZigCompilerNotBuiltWithLLVMExtensions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I forgot about this. I'll open another issue for making zig support writing import libraries from def files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Vexu I will need your help integrating the arocc's |
I don't think there's going to be an easy way to do so because of the bootstrapping process. I'd just copy the generated files from the cache and replace the def files. |
One possible option would be to add a stubbed def file and then in CMake add that as the module for the def files for the purpose of bootstrapping. For building them regularly it should be easy enough to copy some parts from Aro's This should enable bootstrapping: pub fn with(comptime Properties: type) type {
return struct {
tag: Tag = @enumFromInt(0),
properties: Properties = undefined,
pub const max_param_count = 1;
pub const longest_name = 0;
pub const data = [_]@This(){.{}};
pub inline fn fromName(_: []const u8) ?@This() {
return if (@hasField(Properties, "declspec")) null else .{};
}
pub fn nameFromUniqueIndex(_: u16, _: []u8) []u8 {
return "";
}
pub fn uniqueIndex(_: []const u8) ?u16 {
return null;
}
pub const Tag = enum(u16) { _ };
pub fn nameFromTag(_: Tag) NameBuf {
return .{};
}
pub fn tagFromName(name: []const u8) ?Tag {
return @enumFromInt(name.len);
}
pub const NameBuf = struct {
pub fn span(_: *const NameBuf) []const u8 {
return "";
}
};
};
} |
ref: 45eb8a700bfa885af7144a54ffd01f291c6f598f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot about the "file exists in multiple modules" error again and made the stub work for both. It could be simplified for them individually but this works too.
I simplified the names stub while fixing the build error.
1459d8a
to
caa2c12
Compare
The issue I was seeing was that stage3 was unable to build the zig compiler due to not finding the def files. I fixed it with the following diff:
I'm not sure if this is the correct fix; I also did this without your changes to this branch or to aro from today. |
Please don't add any additional logic to CMakeLists.txt. Zig should depend on Aro only as a set of zig files. I don't want to add any Aro-related build system logic to zig's build process. |
Co-authored-by: Veikka Tuominen <[email protected]>
I think the issue was Vexu/arocc@9f4c28a |
If we want to completely eliminate the |
Based on manual testing, this produces the same output for
kernel32.def
when compared to clang, other than minor whitespace differences (clang puts a newline at the beginning, and a trailing space on one line which aro does not)Testing steps:
test.c
zig build-lib -target x86_64-windows-gnu -lkernel32 --verbose-cc test.c
a. This will print a
zig clang
line to stderr; the output path is the final argument./zig-out/bin/zig build-lib -target x86_64-windows-gnu -lkernel32 --verbose-cc test.c
a. This will print
output path: <ZIG_CACHE_PATH>/o/<SOME HASH>/kernel32.def
x86_64-windows-gnu
,x86-windows-gnu
,arm-windows-gnu
,aarch64-windows-gnu
I manually tested error handling by editing
kernel32.def.in
to have an invalid preprocessing directive and got the following:Closes #17753