Comments (8)
Does setting the CLANG_PATH
environment variable to clang-cl
fix this issue?
from mozjs.
I've just tested that, and that doesn't do anything. Neither bindgen
, nor libclang
have any handling for such an environment variable as far I have seen.
from mozjs.
bindgen uses libclang-sys
, which documents CLANG_PATH
here: https://github.com/KyleMayes/clang-sys?tab=readme-ov-file#environment-variables
The usage area is here in bindgen, which calls this function in clang-sys.
But I guess this maybe only affects the clang
executable which is used to detect the include paths, and perhaps does not affect the parsing of arguments, which might be done directly via libclang
.
from mozjs.
Looking at the libclang
source, it directly adds clang
to the args.
https://github.com/llvm/llvm-project/blob/release/18.x/clang/tools/libclang/CIndex.cpp#L4097
There's also no codepath to switch it to clang-cl
reasonably.
Stack is along the lines of:
bindgen::ir::context::BindgenContext::new
-> bindgen::clang::TranslationUnit::parse
-> clang_sys::clang_parseTranslationUnit
(C++) -> clang_sys::clang_parseTranslationUnit2
(C++, adds the clang
) -> clang_sys::clang_parseTranslationUnit2FullArgv
(C++) -> clang_sys::clang_parseTranslationUnit_Impl
(C++)
It would be possible to use clang_parseTranslationUnit2FullArgv
directly, but I can't really think of an API that makes sense for that.
from mozjs.
https://llvm.org/devmtg/2014-04/PDFs/Talks/clang-cl.pdf mentions clang-cl.exe == clang.exe --driver-mode=cl
Does adding --driver-mode=cl
as a clang argument to the builder help?
from mozjs.
That seems to half-work at least. It at least needs /clang:-fuse-ld=lld
, /link /SUBSYSTEM:WINDOWS
, /TP
(instead of -x c++
), /FI
(instead of -include
). Haven't tested it in a full build, currently at this:
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:
clang "./src/jsapi.hpp" "-I" "<omitted>/dist/include" "-I" "<omitted>/js/src" "/TP" -fms-compatibility --driver-mode=cl /clang:-flto=thin /clang:-fuse-ld=lld "-DRUST_BINDGEN" "-DSTATIC_JS_API" "-std:c++17" "-DWIN32" "-D_CRT_USE_BUILTIN_OFFSETOF" "/FI" "<omitted>/js/src/js-confdefs.h" /link /SUBSYSTEM:WINDOWS
from mozjs.
The /link
causes problems though as it's a catch-all, so no inputs are detected, causing stacker
for example to fail to build.
Command "clang-cl" "-nologo" "-MD" "-O2" "-Brepro" "-m64" "--driver-mode=cl" "/clang:-flto=thin" "/clang:-fuse-ld=lld" "/link" "/SUBSYSTEM:WINDOWS" "-I" "src/arch" "-DWINDOWS" "-FoC:\\Users\\Redfire\\spiderfire\\target\\x86_64-pc-windows-msvc\\release\\build\\stacker-a0dccd7a5f938667\\out\\src/arch/windows.o" "-c" "--" "src/arch/windows.c" with args "clang-cl" did not execute successfully
from mozjs.
Given that BINDGEN_EXTRA_CLANG_ARGS
exists, it might be best to just stop adding CFLAGS
and CXXFLAGS
to bindgen.
from mozjs.
Related Issues (20)
- generate_wrappers.sh only works on Clean Builds HOT 1
- Add cross compilation testing HOT 3
- Build Failure on Windows with LLVM 17.0.1 HOT 8
- Match folder names to crate names. HOT 1
- crates.io update HOT 2
- Windows Path Too Long HOT 3
- feat: add a feature flag to build from source HOT 6
- Make TypedArray::update safe HOT 3
- libicu linker errors HOT 6
- Notes on ESR 128 HOT 13
- build script: Respect same environment variables as `cc-rs`
- Enable #[deny(improper_ctypes)] HOT 4
- CI: `integrity` CI job is failing HOT 2
- try_compile does not respect `TARGET_CFLAGS` HOT 1
- streams code in jsglue/japi is always enabled
- Notes on ESR141
- Improve debugging experience when debugging host != build machine HOT 3
- Add OpenHarmony support to Spidermonkey for logging HOT 1
- jsglue sizeOfBuffer has UB in release mode HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mozjs.