44
44
45
45
# A (fake) deterministic emscripten path to use in __FILE__ macro and debug info
46
46
# to produce reproducible builds across platforms.
47
- DETERMINISITIC_PREFIX = '/emsdk/emscripten'
47
+ DETERMINISTIC_PREFIX = '/emsdk/emscripten'
48
48
49
49
50
50
def files_in_path (path , filenames ):
@@ -58,7 +58,7 @@ def glob_in_path(path, glob_pattern, excludes=()):
58
58
return sorted (f for f in files if os .path .basename (f ) not in excludes )
59
59
60
60
61
- def get_base_cflags (force_object_files = False , preprocess = True ):
61
+ def get_base_cflags (build_dir , force_object_files = False , preprocess = True ):
62
62
# Always build system libraries with debug information. Non-debug builds
63
63
# will ignore this at link time because we link with `-strip-debug`.
64
64
flags = ['-g' , '-sSTRICT' , '-Werror' ]
@@ -70,6 +70,12 @@ def get_base_cflags(force_object_files=False, preprocess=True):
70
70
flags += ['-DEMSCRIPTEN_DYNAMIC_LINKING' ]
71
71
if settings .MEMORY64 :
72
72
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 } ' ]
73
79
return flags
74
80
75
81
@@ -462,7 +468,7 @@ def generate_ninja(self, build_dir, libname):
462
468
self .build_dir = build_dir
463
469
464
470
cflags = self .get_cflags ()
465
- asflags = get_base_cflags (preprocess = False )
471
+ asflags = get_base_cflags (self . build_dir , preprocess = False )
466
472
input_files = self .get_files ()
467
473
ninja_file = os .path .join (build_dir , 'build.ninja' )
468
474
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):
491
497
# .s files are processed directly by the assembler. In this case we can't pass
492
498
# pre-processor flags such as `-I` and `-D` but we still want core flags such as
493
499
# `-sMEMORY64`.
494
- cmd += get_base_cflags (preprocess = False )
500
+ cmd += get_base_cflags (self . build_dir , preprocess = False )
495
501
else :
496
502
cmd += cflags
497
503
cmd = self .customize_build_cmd (cmd , src )
@@ -581,16 +587,10 @@ def get_cflags(self):
581
587
Override and add any flags as needed to handle new variations.
582
588
"""
583
589
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 )
585
591
586
592
if self .includes :
587
593
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 } ' ]
594
594
return cflags
595
595
596
596
def get_base_name_prefix (self ):
0 commit comments