emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.69k stars 3.29k forks source link

emar: --em-config option is passed to llvm-ar causing llvm-ar to fail #2886

Closed floooh closed 9 years ago

floooh commented 9 years ago

It looks like emar reads the --em-config cmd line param, but then passes it to llvm-ar which complains about it and stops:

Here's output from calling emar with a non-standard .emscripten file location:

FlohOfWoe:emscripten floh$ ./emar --em-config ~/projects/oryol/sdks/osx/.emscripten
llvm-ar: Unknown command line argument '--em-config'.  Try: '/Users/floh/projects/oryol/sdks/osx/emscripten-fastcomp/build/Release/bin/llvm-ar -help'
llvm-ar: Did you mean '-version'?
llvm-ar: Not enough positional command line arguments specified!
Must specify at least 2 positional arguments: See: /Users/floh/projects/oryol/sdks/osx/emscripten-fastcomp/build/Release/bin/llvm-ar -help

emar recognizes the --em-config option, and loads the .emscripten file, but then doesn't remove the option before calling llvm-ar.

kripken commented 9 years ago

It doesn't look like emar has any support for --em-config? I think just emcc has that. Would it be useful if we added it to emar?

waywardmonkeys commented 9 years ago

emar does in fact obey --em-config, but indirectly.

This code is at top level in tools/shared.py:

try:
  EM_CONFIG = sys.argv[sys.argv.index('--em-config')+1]
  # Emscripten compiler spawns other processes, which can reimport shared.py, so make sure that
  # those child processes get the same configuration file by setting it to the currently active environment.
  os.environ['EM_CONFIG'] = EM_CONFIG
except:
  EM_CONFIG = os.environ.get('EM_CONFIG')
waywardmonkeys commented 9 years ago

I have a patch for this.

floooh commented 9 years ago

Yay cool :) Some background info for @kripken:

oryol (https://github.com/floooh/oryol) tries to install 3rd party sdks (e.g. emscripten or the android ndk) in a local subdirectory without messing up global settings on the machine (central config files, environemnt variables, registry settings). This works because the project's build system has its own cmake toolchain files which can override most default settings and is generally useful because it doesn't mess with any other SDKs installed on the same machine, and oryol automatically can pin emscripten to a specific version if needed.

I think currently this also only works with directly checking out emscripten and fastcomp 'the old way', not with the official emscripten SDK (this seems to always write .emscripten to ~/.emscripten).

kripken commented 9 years ago

Ok, I see. Let's continue discussion in that pull.