Skip to content

Add support for "local" sub-directory of sysroot #13769

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,11 @@ def emsdk_ldflags(user_args):
if os.environ.get('EMMAKEN_NO_SDK'):
return []

sysroot = shared.Cache.get_sysroot_dir()
library_paths = [
shared.Cache.get_lib_dir(absolute=True)
os.path.join(sysroot, 'local', 'lib'),
os.path.join(shared.Cache.dirname, shared.Cache.get_lib_dir()),
os.path.join(sysroot, 'lib'),
]
ldflags = ['-L' + l for l in library_paths]

Expand All @@ -680,7 +683,7 @@ def emsdk_ldflags(user_args):


def emsdk_cflags(user_args):
cflags = ['--sysroot=' + shared.Cache.get_sysroot_dir(absolute=True)]
cflags = ['--sysroot=' + shared.Cache.get_sysroot_dir()]

def array_contains_any_of(hay, needles):
for n in needles:
Expand Down Expand Up @@ -713,7 +716,14 @@ def array_contains_any_of(hay, needles):
if array_contains_any_of(user_args, SIMD_NEON_FLAGS):
cflags += ['-D__ARM_NEON__=1']

return cflags + ['-Xclang', '-iwithsysroot' + os.path.join('/include', 'compat')]
include_paths = [
'/local/include',
'/include/compat',
]
for p in include_paths:
cflags += ['-Xclang', '-iwithsysroot' + p]

return cflags


def get_clang_flags():
Expand Down
4 changes: 4 additions & 0 deletions tools/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ def configure(args, stdout=None, stderr=None, env=None, cflags=[], **kwargs):
# compilation with emcc, but instead do builds natively with Clang. This
# is a heuristic emulation that may or may not work.
env['EMMAKEN_JUST_CONFIGURE'] = '1'
if not any(a.startswith('--prefix') for a in args):
sysroot = shared.Cache.get_sysroot_dir()
args.append('--prefix=' + os.path.join(sysroot, 'local'))

if EM_BUILD_VERBOSE >= 2:
stdout = None
if EM_BUILD_VERBOSE >= 1:
Expand Down
14 changes: 6 additions & 8 deletions tools/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,14 @@ def erase(self):
def get_path(self, name):
return os.path.join(self.dirname, name)

def get_sysroot_dir(self, absolute):
if absolute:
return os.path.join(self.dirname, 'sysroot')
return 'sysroot'
def get_sysroot_dir(self):
return os.path.join(self.dirname, 'sysroot')

def get_include_dir(self):
return os.path.join(self.get_sysroot_dir(absolute=True), 'include')
return os.path.join(self.get_sysroot_dir(), 'include')

def get_lib_dir(self, absolute):
path = os.path.join(self.get_sysroot_dir(absolute=absolute), 'lib')
def get_lib_dir(self):
path = os.path.join('sysroot', 'lib')
if shared.Settings.MEMORY64:
path = os.path.join(path, 'wasm64-emscripten')
else:
Expand All @@ -113,7 +111,7 @@ def get_lib_dir(self, absolute):
return path

def get_lib_name(self, name):
return os.path.join(self.get_lib_dir(absolute=False), name)
return os.path.join(self.get_lib_dir(), name)

def erase_lib(self, name):
self.erase_file(self.get_lib_name(name))
Expand Down