aboutsummaryrefslogtreecommitdiff
path: root/emcc
diff options
context:
space:
mode:
Diffstat (limited to 'emcc')
-rwxr-xr-xemcc66
1 files changed, 48 insertions, 18 deletions
diff --git a/emcc b/emcc
index ce5b499e..9eafd685 100755
--- a/emcc
+++ b/emcc
@@ -1127,6 +1127,44 @@ try:
os.path.join('libc', 'stdlib', 'strtod.c'),
];
+ musl_files = []
+
+ for directory, sources in musl_files:
+ libc_files += [os.path.join('libc', 'musl', 'src', directory, source) for source in sources]
+
+ prev_cxx = os.environ.get('EMMAKEN_CXX')
+ if prev_cxx: os.environ['EMMAKEN_CXX'] = ''
+ musl_internal_includes = shared.path_from_root('system', 'lib', 'libc', 'musl', 'src', 'internal')
+ for src in libc_files:
+ o = in_temp(os.path.basename(src) + '.o')
+ execute([shared.PYTHON, shared.EMCC, shared.path_from_root('system', 'lib', src), '-o', o, '-I', musl_internal_includes], stdout=stdout, stderr=stderr)
+ o_s.append(o)
+ if prev_cxx: os.environ['EMMAKEN_CXX'] = prev_cxx
+
+ shared.Building.link(o_s, in_temp('libc.bc'))
+ return in_temp('libc.bc')
+
+ def fix_libc(need):
+ # libc needs some sign correction. # If we are in mode 0, switch to 2. We will add our lines
+ try:
+ if shared.Settings.CORRECT_SIGNS == 0: raise Exception('we need to change to 2')
+ except: # we fail if equal to 0 - so we need to switch to 2 - or if CORRECT_SIGNS is not even in Settings
+ shared.Settings.CORRECT_SIGNS = 2
+ if shared.Settings.CORRECT_SIGNS == 2:
+ shared.Settings.CORRECT_SIGNS_LINES = [shared.path_from_root('src', 'dlmalloc.c') + ':' + str(i+4) for i in [4816, 4191, 4246, 4199, 4205, 4235, 4227]]
+ # If we are in mode 1, we are correcting everything anyhow. If we are in mode 3, we will be corrected
+ # so all is well anyhow too.
+ # XXX We also need to add libc symbols that use malloc, for example strdup. It's very rare to use just them and not
+ # a normal malloc symbol (like free, after calling strdup), so we haven't hit this yet, but it is possible.
+ libc_symbols = map(lambda line: line.strip().split(' ')[1], open(shared.path_from_root('system', 'lib', 'libc.symbols')).readlines())
+ libc_symbols = set(libc_symbols)
+
+ # libcextra
+ def create_libcextra():
+ if DEBUG: print >> sys.stderr, 'emcc: building libcextra for cache'
+ o_s = []
+ libcextra_files = []
+
musl_files = [
['multibyte', [
'btowc.c',
@@ -1177,35 +1215,26 @@ try:
]]
]
+ libcextra_files = []
for directory, sources in musl_files:
- libc_files += [os.path.join('libc', 'musl', 'src', directory, source) for source in sources]
+ libcextra_files += [os.path.join('libc', 'musl', 'src', directory, source) for source in sources]
prev_cxx = os.environ.get('EMMAKEN_CXX')
if prev_cxx: os.environ['EMMAKEN_CXX'] = ''
musl_internal_includes = shared.path_from_root('system', 'lib', 'libc', 'musl', 'src', 'internal')
- for src in libc_files:
+ for src in libcextra_files:
o = in_temp(os.path.basename(src) + '.o')
execute([shared.PYTHON, shared.EMCC, shared.path_from_root('system', 'lib', src), '-o', o, '-I', musl_internal_includes], stdout=stdout, stderr=stderr)
o_s.append(o)
if prev_cxx: os.environ['EMMAKEN_CXX'] = prev_cxx
- shared.Building.link(o_s, in_temp('libc.bc'))
- return in_temp('libc.bc')
+ shared.Building.link(o_s, in_temp('libcextra.bc'))
+ return in_temp('libcextra.bc')
- def fix_libc(need):
- # libc needs some sign correction. # If we are in mode 0, switch to 2. We will add our lines
- try:
- if shared.Settings.CORRECT_SIGNS == 0: raise Exception('we need to change to 2')
- except: # we fail if equal to 0 - so we need to switch to 2 - or if CORRECT_SIGNS is not even in Settings
- shared.Settings.CORRECT_SIGNS = 2
- if shared.Settings.CORRECT_SIGNS == 2:
- shared.Settings.CORRECT_SIGNS_LINES = [shared.path_from_root('src', 'dlmalloc.c') + ':' + str(i+4) for i in [4816, 4191, 4246, 4199, 4205, 4235, 4227]]
- # If we are in mode 1, we are correcting everything anyhow. If we are in mode 3, we will be corrected
- # so all is well anyhow too.
- # XXX We also need to add libc symbols that use malloc, for example strdup. It's very rare to use just them and not
- # a normal malloc symbol (like free, after calling strdup), so we haven't hit this yet, but it is possible.
- libc_symbols = map(lambda line: line.strip().split(' ')[1], open(shared.path_from_root('system', 'lib', 'libc.symbols')).readlines())
- libc_symbols = set(libc_symbols)
+ def fix_libcextra(need):
+ pass
+ libcextra_symbols = map(lambda line: line.strip().split(' ')[1], open(shared.path_from_root('system', 'lib', 'libcextra.symbols')).readlines())
+ libcextra_symbols = set(libcextra_symbols)
# libcxx
def create_libcxx():
@@ -1279,6 +1308,7 @@ try:
force = os.environ.get('EMCC_FORCE_STDLIBS')
has = need = None
for name, create, fix, library_symbols in [('libcxx', create_libcxx, fix_libcxx, libcxx_symbols),
+ ('libcextra', create_libcextra, fix_libcextra, libcextra_symbols),
('libcxxabi', create_libcxxabi, fix_libcxxabi, libcxxabi_symbols),
('libc', create_libc, fix_libc, libc_symbols)]:
if not force: