4444
4545# A (fake) deterministic emscripten path to use in __FILE__ macro and debug info
4646# to produce reproducible builds across platforms.
47- DETERMINISITIC_PREFIX = '/emsdk/emscripten'
47+ DETERMINISTIC_PREFIX = '/emsdk/emscripten'
4848
4949
5050def files_in_path (path , filenames ):
@@ -58,7 +58,7 @@ def glob_in_path(path, glob_pattern, excludes=()):
5858 return sorted (f for f in files if os .path .basename (f ) not in excludes )
5959
6060
61- def get_base_cflags (force_object_files = False , preprocess = True ):
61+ def get_base_cflags (build_dir , force_object_files = False , preprocess = True ):
6262 # Always build system libraries with debug information. Non-debug builds
6363 # will ignore this at link time because we link with `-strip-debug`.
6464 flags = ['-g' , '-sSTRICT' , '-Werror' ]
@@ -70,6 +70,12 @@ def get_base_cflags(force_object_files=False, preprocess=True):
7070 flags += ['-DEMSCRIPTEN_DYNAMIC_LINKING' ]
7171 if settings .MEMORY64 :
7272 flags += ['-Wno-experimental' , '-sMEMORY64=' + str (settings .MEMORY64 )]
73+
74+ source_dir = utils .path_from_root ()
75+ relative_source_dir = os .path .relpath (source_dir , build_dir )
76+ flags += [f'-ffile-prefix-map={ source_dir } ={ DETERMINISTIC_PREFIX } ' ,
77+ f'-ffile-prefix-map={ relative_source_dir } ={ DETERMINISTIC_PREFIX } ' ,
78+ f'-fdebug-compilation-dir={ DETERMINISTIC_PREFIX } ' ]
7379 return flags
7480
7581
@@ -462,7 +468,7 @@ def generate_ninja(self, build_dir, libname):
462468 self .build_dir = build_dir
463469
464470 cflags = self .get_cflags ()
465- asflags = get_base_cflags (preprocess = False )
471+ asflags = get_base_cflags (self . build_dir , preprocess = False )
466472 input_files = self .get_files ()
467473 ninja_file = os .path .join (build_dir , 'build.ninja' )
468474 create_ninja_file (input_files , ninja_file , libname , cflags , asflags = asflags , customize_build_flags = self .customize_build_cmd )
@@ -491,7 +497,7 @@ def build_objects(self, build_dir):
491497 # .s files are processed directly by the assembler. In this case we can't pass
492498 # pre-processor flags such as `-I` and `-D` but we still want core flags such as
493499 # `-sMEMORY64`.
494- cmd += get_base_cflags (preprocess = False )
500+ cmd += get_base_cflags (self . build_dir , preprocess = False )
495501 else :
496502 cmd += cflags
497503 cmd = self .customize_build_cmd (cmd , src )
@@ -581,16 +587,10 @@ def get_cflags(self):
581587 Override and add any flags as needed to handle new variations.
582588 """
583589 cflags = self ._inherit_list ('cflags' )
584- cflags += get_base_cflags (force_object_files = self .force_object_files )
590+ cflags += get_base_cflags (self . build_dir , force_object_files = self .force_object_files )
585591
586592 if self .includes :
587593 cflags += ['-I' + utils .path_from_root (i ) for i in self ._inherit_list ('includes' )]
588-
589- source_dir = utils .path_from_root ()
590- relative_source_dir = os .path .relpath (source_dir , self .build_dir )
591- cflags += [f'-ffile-prefix-map={ source_dir } ={ DETERMINISITIC_PREFIX } ' ,
592- f'-ffile-prefix-map={ relative_source_dir } ={ DETERMINISITIC_PREFIX } ' ,
593- f'-fdebug-compilation-dir={ DETERMINISITIC_PREFIX } ' ]
594594 return cflags
595595
596596 def get_base_name_prefix (self ):
0 commit comments