-
Notifications
You must be signed in to change notification settings - Fork 118
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
Windows Builds Fail when clang-cl
Flags are added to CXXFLAGS
#435
Comments
Does setting the |
I've just tested that, and that doesn't do anything. Neither |
bindgen uses The usage area is here in bindgen, which calls this function in clang-sys. But I guess this maybe only affects the |
Looking at the There's also no codepath to switch it to Stack is along the lines of: It would be possible to use |
https://llvm.org/devmtg/2014-04/PDFs/Talks/clang-cl.pdf mentions Does adding |
That seems to half-work at least. It at least needs lld-link: error: undefined symbol: WinMain
>>> referenced by D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:102
>>> libcmt.lib(exe_winmain.obj):(int __cdecl invoke_main(void))
>>> referenced by D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
>>> libcmt.lib(exe_winmain.obj):(int __cdecl __scrt_common_main_seh(void))
clang: error: linker command failed with exit code 1 (use -v to see invocation) Command:
|
The
|
Given that |
The root issue here is that bindgen uses
clang
(notclang-cl
) on windows, and on unrecognised flags, it fails. Upon addingCXXFLAGS="/clang:-flto=thin /clang:-fuse-ld=lld-link"
, the below code automatically adds it to bindgen's flags as well. As/clang:
flags are only recognised byclang-cl
, there is no way forcc
and themakefile.cargo
to receive theCXXFLAGS
but not bindgen.mozjs/mozjs-sys/build.rs
Lines 334 to 338 in c7fb1b8
There are a few possible approaches:
/clang:
on windows, do not add it to bindgen.BINDGEN_CXXFLAGS
variable for bindgen's flags.As said earlier, the root issue is the usage of
clang
, which means this error may not be just from/clang:
flags but almost anycl
flag. Hence, I would suggest the latter approach.For a concrete example of the failure, see https://github.com/Redfire75369/spiderfire/actions/runs/7112793006/job/19363443030#step:6:18053, where a
libclang error
is caused.In the event it matters for updating whatever depends on it, #136 was the original PR where this behaviour was introduced.
The text was updated successfully, but these errors were encountered: