File emscripten-cflags.patch of Package nodejs-vscode-oniguruma
--- a/tools/system_libs.py
+++ b/tools/system_libs.py
@@ -50,7 +50,7 @@ def get_base_cflags(force_object_files=F
flags += ['-sRELOCATABLE']
if settings.MEMORY64:
flags += ['-Wno-experimental', '-sMEMORY64=' + str(settings.MEMORY64)]
- return flags
+ return flags + os.environ['CFLAGS'].split()
def clean_env():
@@ -59,7 +59,7 @@ def clean_env():
# At least one port also uses autoconf (harfbuzz) so we also need to clear
# CFLAGS/LDFLAGS which we don't want to effect the inner call to configure.
safe_env = os.environ.copy()
- for opt in ['CFLAGS', 'CXXFLAGS', 'LDFLAGS',
+ for opt in [
'EMCC_CFLAGS',
'EMCC_FORCE_STDLIBS',
'EMCC_ONLY_FORCED_STDLIBS',
@@ -178,7 +178,7 @@ class Library:
# extra code size. The -fno-unroll-loops flags was added here when loop
# unrolling landed upstream in LLVM to avoid changing behavior but was not
# specifically evaluated.
- cflags = ['-O2', '-Werror', '-fno-unroll-loops']
+ cflags = os.environ['CFLAGS'].split()
# A list of directories to put in the include path when building.
# This is a list of tuples of path components.
@@ -1003,7 +1003,7 @@ class libc(MuslInternalLibrary,
return libc_files
def customize_build_cmd(self, cmd, filename):
- if filename in self.non_lto_files:
+ if filename.endswith('/sqrtl.c'):
# These files act more like the part of compiler-rt in that
# references to them can be generated at compile time.
# Treat them like compiler-rt in as much as never compile
@@ -1011,8 +1011,7 @@ class libc(MuslInternalLibrary,
# use used for the rest of libc) because this set of files
# also contains performance sensitive math functions.
- cmd = [a for a in cmd if not a.startswith('-flto')]
- cmd = [a for a in cmd if not a.startswith('-O')]
- cmd += ['-O2']
+ # this file crashes the compiler otherwise
+ cmd = [a for a in cmd if not a.startswith('-fstack-protector')]
return cmd
@@ -1055,11 +1053,9 @@ class libc_optz(libc):
return libcall_files + mem_files
def customize_build_cmd(self, cmd, filename):
- if filename in self.non_lto_files:
+ if filename.endswith('/sqrtl.c'):
# see comments in libc.customize_build_cmd
- cmd = [a for a in cmd if not a.startswith('-flto')]
- cmd = [a for a in cmd if not a.startswith('-O')]
- cmd += ['-O2']
+ cmd = [a for a in cmd if not a.startswith('-fstack-protector')]
return cmd
def can_use(self):