You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[feature request] Option for a custom compiler wrapper path for emmake / emconfigure / emcmake (EM_COMPILER_WRAPPER?) #12256
Is there another recommended way for achieveing this? If not, I propose adding some option to emcc that would achieve the same. and would be more discoverable.
Ideally a given build system would support cross compiling fully and be aware of the difference between the host toolchain and the target toolchain.
It sounds like this tool is designed to work around build system that don't fully support cross compiling and assume that build-time builds are built with the same compiler?
Perhaps such tool is useful, but maybe its not specific to emscripten and would be useful for all cross compilers? Or is there something emscripten-specific about this?
Also just to be clear if you skip binary foo then all the object files that go into foo are still compiled right? Only the final link is skipped and replaced with a copy?
Also just to be clear if you skip binary foo then all the object files that go into foo are still compiled right? Only the final link is skipped and replaced with a copy?
This tools is a hack to have something just enough to get TexLive and its many dependencies to compile, so yes, it just skips compiling the wasm tools (another solution is to let them being compiled, and replace them after, but this requires a very delicate surgery of the build process), object files are still being built
It sounds like this tool is designed to work around build system that don't fully support cross compiling and assume that build-time builds are built with the same compiler?
Correct!
(I didn't try to use cross-compling support of TexLive, it might work, but all previous work at this didn't do this, so I didn't either)
A more general solution "for porting hacks" would be some DSL or config that specifies some behavior on some condition (e.g. output object matches some glob). Behaviors may be append/redefine some define or CFLAG, append/prepend linker flags. Otherwise complex ports become a journey into studying the build system.
Some Makefiles propagate CC env variable to children, some do not etc. Sometimes resetting make CFLAGS=... is not propagated and make -e CFLAGS would be needed. But that destroys preconfigured CFLAGS. So I resort to CC=... or -e CC=... just to override some CFLAGS.
Sometimes it's not easily possible to configure some part of source tree without destroying configuration for other part, that's why I have to build dependencies in some particular order in my busytex setup
The implementation of emmake is just to run make with a specific environment set. This is the code that creates the environment (from building.py)
def get_building_env(cflags=[]):
env = os.environ.copy()
# point CC etc. to the em* tools.
env['CC'] = EMCC
env['CXX'] = EMXX
env['AR'] = EMAR
env['LD'] = EMCC
env['NM'] = LLVM_NM
env['LDSHARED'] = EMCC
env['RANLIB'] = EMRANLIB
env['EMSCRIPTEN_TOOLS'] = path_from_root('tools')
if cflags:
env['CFLAGS'] = env['EMMAKEN_CFLAGS'] = ' '.join(cflags)
env['HOST_CC'] = CLANG_CC
env['HOST_CXX'] = CLANG_CXX
env['HOST_CFLAGS'] = "-W" # if set to nothing, CFLAGS is used, which we don't want
env['HOST_CXXFLAGS'] = "-W" # if set to nothing, CXXFLAGS is used, which we don't want
env['PKG_CONFIG_LIBDIR'] = path_from_root('system', 'local', 'lib', 'pkgconfig') + os.path.pathsep + path_from_root('system', 'lib', 'pkgconfig') env['PKG_CONFIG_PATH'] = os.environ.get('EM_PKG_CONFIG_PATH', '')
env['EMSCRIPTEN'] = path_from_root()
env['PATH'] = path_from_root('system', 'bin') + os.pathsep + env['PATH']
env['CROSS_COMPILE'] = path_from_root('em') # produces /path/to/emscripten/em , which then can have 'cc', 'ar', etc appended to it
return env
I would recommend creating your own script that configures the environment you wan can uses your compiler wrapper script. Then it can function completely independently of emscripten.
changed the title [-][feature request] emcc option for copy-pasting a third-party binary instead of compiling[/-][+][feature request] Option for a custom compiler wrapper path for emmake / emconfigure / emcmake (EM_COMPILER_WRAPPER?)[/+]on Sep 24, 2020
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.
The implementation of emmake is just to run make with a specific environment set. This is the code that creates the environment (from building.py)
def get_building_env(cflags=[]):
env = os.environ.copy()
# point CC etc. to the em* tools.
env['CC'] = EMCC
env['CXX'] = EMXX
env['AR'] = EMAR
env['LD'] = EMCC
env['NM'] = LLVM_NM
env['LDSHARED'] = EMCC
env['RANLIB'] = EMRANLIB
env['EMSCRIPTEN_TOOLS'] = path_from_root('tools')
if cflags:
env['CFLAGS'] = env['EMMAKEN_CFLAGS'] = ' '.join(cflags)
env['HOST_CC'] = CLANG_CC
env['HOST_CXX'] = CLANG_CXX
env['HOST_CFLAGS'] = "-W" # if set to nothing, CFLAGS is used, which we don't want
env['HOST_CXXFLAGS'] = "-W" # if set to nothing, CXXFLAGS is used, which we don't want
env['PKG_CONFIG_LIBDIR'] = path_from_root('system', 'local', 'lib', 'pkgconfig') + os.path.pathsep + path_from_root('system', 'lib', 'pkgconfig') env['PKG_CONFIG_PATH'] = os.environ.get('EM_PKG_CONFIG_PATH', '')
env['EMSCRIPTEN'] = path_from_root()
env['PATH'] = path_from_root('system', 'bin') + os.pathsep + env['PATH']
env['CROSS_COMPILE'] = path_from_root('em') # produces /path/to/emscripten/em , which then can have 'cc', 'ar', etc appended to it
return env
I would recommend creating your own script that configures the environment you wan can uses your compiler wrapper script. Then it can function completely independently of emscripten.
It may also be that some makefiles use HOSTCC convention instead of HOST_CC...
Yeah, I propose to support a global environment variable which emcc (or at least emconfigure/emmake/emcmake) could somehow support, this wrapper script could do some custom processing (e.g. flags modification or instead invoke the host compiler) before delegate-invoking the base emcc.
For complex cases, this can allow to centralize all hacks in one compiler wrapper script
Maybe emcc/em++ could detect this env variable and if set, unset it and invoke the wrapper and exit. The wrapper can itself call back into emcc/em++ with this variable unset.
I do it to modify some flags depending on the artifact being built or to copy-out native pre-built executable when cannot set properly host compiler.
Activity
sbc100 commentedon Sep 17, 2020
Ideally a given build system would support cross compiling fully and be aware of the difference between the host toolchain and the target toolchain.
It sounds like this tool is designed to work around build system that don't fully support cross compiling and assume that build-time builds are built with the same compiler?
Perhaps such tool is useful, but maybe its not specific to emscripten and would be useful for all cross compilers? Or is there something emscripten-specific about this?
sbc100 commentedon Sep 17, 2020
BTW I'm not saying I would necessarily be against adding such a tool to emscripten if it was integrated the correct way.
sbc100 commentedon Sep 17, 2020
Also just to be clear if you skip binary foo then all the object files that go into foo are still compiled right? Only the final link is skipped and replaced with a copy?
vadimkantorov commentedon Sep 17, 2020
This tools is a hack to have something just enough to get TexLive and its many dependencies to compile, so yes, it just skips compiling the wasm tools (another solution is to let them being compiled, and replace them after, but this requires a very delicate surgery of the build process), object files are still being built
Correct!
(I didn't try to use cross-compling support of TexLive, it might work, but all previous work at this didn't do this, so I didn't either)
vadimkantorov commentedon Sep 17, 2020
A more general solution "for porting hacks" would be some DSL or config that specifies some behavior on some condition (e.g. output object matches some glob). Behaviors may be append/redefine some define or CFLAG, append/prepend linker flags. Otherwise complex ports become a journey into studying the build system.
Some Makefiles propagate CC env variable to children, some do not etc. Sometimes resetting
make CFLAGS=...is not propagated andmake -e CFLAGSwould be needed. But that destroys preconfigured CFLAGS. So I resort toCC=...or-e CC=...just to override some CFLAGS.Sometimes it's not easily possible to configure some part of source tree without destroying configuration for other part, that's why I have to build dependencies in some particular order in my busytex setup
vadimkantorov commentedon Sep 17, 2020
Is it possible to set some compiler-wrapper (e.g. some tool like one described above) to be used by emmake instead of emcc/em++?
sbc100 commentedon Sep 17, 2020
The implementation of emmake is just to run make with a specific environment set. This is the code that creates the environment (from building.py)
I would recommend creating your own script that configures the environment you wan can uses your compiler wrapper script. Then it can function completely independently of emscripten.
vadimkantorov commentedon Sep 18, 2020
Then I'd also need to dump emcmake and emconfigure :(
sbc100 commentedon Sep 18, 2020
I think we could add an extra EM_COMPILER_WRAPPER environment variable that emcmake and emconfigure could honor?
sbc100 commentedon Sep 18, 2020
Might be useful for things
distcctoo.vadimkantorov commentedon Sep 18, 2020
For now, would executing something like this remove the need of emconfigure / emcmake / make (in some simple case)?
vadimkantorov commentedon Sep 18, 2020
Hmm, my configure did not like this approach: "configure: WARNING: you should use --build, --host, --target"
[-][feature request] emcc option for copy-pasting a third-party binary instead of compiling[/-][+][feature request] Option for a custom compiler wrapper path for emmake / emconfigure / emcmake (EM_COMPILER_WRAPPER?)[/+]stale commentedon Sep 26, 2021
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.
vadimkantorov commentedon Sep 27, 2021
The issue is still standing...
vadimkantorov commentedon Dec 29, 2022
It may also be that some makefiles use
HOSTCCconvention instead ofHOST_CC...vadimkantorov commentedon Aug 11, 2026
It can be sometimes much simpler to have such a compiler wrapper, than properly solving https://tug.org/texinfohtml/tlbuild.html#Cross-problems-1 (can be simpler to pretend that target compiler produced a host artifact than making sure that one given binary artifact is compiled with host compiler)
sbc100 commentedon Aug 11, 2026
Can this issue be closed since #12380 added EM_COMPILER_WRAPPER ?
sbc100 commentedon Aug 11, 2026
Oh, no sorry,
EM_COMPILER_WRAPPERis a wrapper for the inner clang process.vadimkantorov commentedon Aug 14, 2026
Yeah, I propose to support a global environment variable which emcc (or at least emconfigure/emmake/emcmake) could somehow support, this wrapper script could do some custom processing (e.g. flags modification or instead invoke the host compiler) before delegate-invoking the base emcc.
For complex cases, this can allow to centralize all hacks in one compiler wrapper script
vadimkantorov commentedon Aug 20, 2026
Maybe emcc/em++ could detect this env variable and if set, unset it and invoke the wrapper and exit. The wrapper can itself call back into emcc/em++ with this variable unset.
I do it to modify some flags depending on the artifact being built or to copy-out native pre-built executable when cannot set properly host compiler.
sbc100 commentedon Aug 20, 2026
Wouldn't it be possible to create these wrappers today without emcc support?
Then you can do whatever you want in your wapper version and then invoke the real emcc by looking for the next thing in the path?
vadimkantorov commentedon Aug 20, 2026
Wouldn't emconfigure/emmake still fetch out abspaths for proper emcc and set CC accordingly, thus circumventing the PATH trick?
sbc100 commentedon Aug 20, 2026
Oh yes, sorry I forget that detail.