aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-12-16 19:08:30 -0800
committerAlon Zakai <alonzakai@gmail.com>2011-12-16 19:08:30 -0800
commit7ae17d41b81474e2a7dce3281195bb5c9c5e7bb2 (patch)
tree507ad89a424eadd6e407b43a74d8880dc9212147
parentd157b2049d07d3396cfa6d646d56705100ef412f (diff)
improve linking in emcc, can now build zlib, openjpeg, freetype
-rwxr-xr-xemcc15
-rw-r--r--tests/runner.py2
-rw-r--r--tools/shared.py10
3 files changed, 14 insertions, 13 deletions
diff --git a/emcc b/emcc
index ebcdb1d3..14c96b01 100755
--- a/emcc
+++ b/emcc
@@ -342,11 +342,9 @@ try:
if DEBUG: print >> sys.stderr, 'emcc: compiling to bitcode'
# First, generate LLVM bitcode. For each input file, we get base.o with bitcode
- newargs = newargs + ['-emit-llvm', '-c']
-
for input_file in input_files:
if input_file.endswith(SOURCE_SUFFIXES):
- args = newargs + [input_file, '-o', in_temp(unsuffixed_basename(input_file) + '.o')]
+ args = newargs + ['-emit-llvm', '-c', input_file, '-o', in_temp(unsuffixed_basename(input_file) + '.o')]
if DEBUG: print >> sys.stderr, "emcc running:", call, ' '.join(args)
Popen([call] + args).communicate()
else: # bitcode
@@ -372,9 +370,12 @@ try:
else:
assert not has_dash_c, 'fatal error: cannot specify -o with -c with multiple files' + str(sys.argv)
# We have a specified target (-o <target>), which is not JavaScript or HTML, and
- # we have multiple files: Link them. TODO: Pass complex linker args along
- shared.Building.link(map(lambda input_file: in_temp(unsuffixed_basename(input_file) + '.o'), input_files), specified_target)
-
+ # we have multiple files: Link them TODO: llvm link-time opts?
+ ld_args = map(lambda input_file: in_temp(unsuffixed_basename(input_file) + '.o'), input_files) + \
+ ['-o', specified_target]
+ #[arg.split('-Wl,')[1] for arg in filter(lambda arg: arg.startswith('-Wl,'), sys.argv)]
+ if DEBUG: print >> sys.stderr, 'emcc: link: ' + str(ld_args)
+ Popen([shared.LLVM_LINK] + ld_args).communicate()
exit(0)
## Continue on to create JavaScript
@@ -416,7 +417,7 @@ try:
if len(input_files) + len(extra_files_to_link) > 1:
shared.Building.link(map(lambda input_file: in_temp(unsuffixed_basename(input_file) + '.o'), input_files) + extra_files_to_link,
in_temp(target_basename + '.bc'))
- # TODO: LLVM link-time opts?
+ # TODO: LLVM link-time opts? here and/or elsewhere?
else:
shutil.move(in_temp(unsuffixed_basename(input_files[0]) + '.o'), in_temp(target_basename + '.bc'))
diff --git a/tests/runner.py b/tests/runner.py
index 03a4c425..dcfd1588 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -3825,7 +3825,7 @@ at function.:blag
shutil.copy(path_from_root('tests', 'openjpeg', 'opj_config.h'), self.get_dir())
lib = self.get_library('openjpeg',
- [os.path.join('bin', 'libopenjpeg.so.1.4.0.bc'),
+ [os.path.join('bin', 'libopenjpeg.so.1.4.0'),
os.path.sep.join('codec/CMakeFiles/j2k_to_image.dir/index.c.o'.split('/')),
os.path.sep.join('codec/CMakeFiles/j2k_to_image.dir/convert.c.o'.split('/')),
os.path.sep.join('codec/CMakeFiles/j2k_to_image.dir/__/common/color.c.o'.split('/')),
diff --git a/tools/shared.py b/tools/shared.py
index 97e953be..a480faa9 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -222,11 +222,11 @@ class Building:
@staticmethod
def get_building_env():
env = os.environ.copy()
- env['CC'] = EMMAKEN #EMCC
- env['CXX'] = EMMAKEN #EMXX
- env['AR'] = EMMAKEN #EMAR
- env['RANLIB'] = EMMAKEN #EMRANLIB
- env['LIBTOOL'] = EMMAKEN #EMLIBTOOL
+ env['CC'] = EMCC
+ env['CXX'] = EMXX
+ env['AR'] = EMAR
+ env['RANLIB'] = EMRANLIB
+ env['LIBTOOL'] = EMLIBTOOL
env['EMMAKEN_COMPILER'] = Building.COMPILER
env['EMSCRIPTEN_TOOLS'] = path_from_root('tools')
env['CFLAGS'] = env['EMMAKEN_CFLAGS'] = ' '.join(COMPILER_OPTS + Building.COMPILER_TEST_OPTS) # Normal CFLAGS is ignored by some configure's.