@@ -151,6 +151,14 @@ def get_wasm_libc_rt_files():
151
151
return math_files + other_files + iprintf_files
152
152
153
153
154
+ def is_case_insensitive (path ):
155
+ """Returns True if the filesystem at `path` is case insensitive."""
156
+ shared .write_file (os .path .join (path , 'test_file' ), '' )
157
+ case_insensitive = os .path .exists (os .path .join (path , 'TEST_FILE' ))
158
+ os .remove (os .path .join (path , 'test_file' ))
159
+ return case_insensitive
160
+
161
+
154
162
class Library :
155
163
"""
156
164
`Library` is the base class of all system libraries.
@@ -343,8 +351,20 @@ def build_objects(self, build_dir):
343
351
objects = []
344
352
cflags = self .get_cflags ()
345
353
base_flags = get_base_cflags ()
354
+ case_insensitive = is_case_insensitive (build_dir )
346
355
for src in self .get_files ():
347
- o = os .path .join (build_dir , shared .unsuffixed_basename (src ) + '.o' )
356
+ object_basename = shared .unsuffixed_basename (src )
357
+ # Resolve duplicates by appending unique.
358
+ # This is needed on case insensitve filesystem to handle,
359
+ # for example, _exit.o and _Exit.o.
360
+ if case_insensitive :
361
+ object_basename = object_basename .lower ()
362
+ o = os .path .join (build_dir , object_basename + '.o' )
363
+ object_uuid = 0
364
+ # Find a unique basename
365
+ while o in objects :
366
+ object_uuid += 1
367
+ o = os .path .join (build_dir , f'{ object_basename } __{ object_uuid } .o' )
348
368
ext = shared .suffix (src )
349
369
if ext in ('.s' , '.S' , '.c' ):
350
370
cmd = [shared .EMCC ]
@@ -704,7 +724,7 @@ def get_files(self):
704
724
'res_query.c' , 'res_querydomain.c' , 'gai_strerror.c' ,
705
725
'proto.c' , 'gethostbyaddr.c' , 'gethostbyaddr_r.c' , 'gethostbyname.c' ,
706
726
'gethostbyname2_r.c' , 'gethostbyname_r.c' , 'gethostbyname2.c' ,
707
- 'alarm.c' , 'syscall.c' , '_exit.c' , ' popen.c' ,
727
+ 'alarm.c' , 'syscall.c' , 'popen.c' ,
708
728
'getgrouplist.c' , 'initgroups.c' , 'wordexp.c' , 'timer_create.c' ,
709
729
'faccessat.c' ,
710
730
# 'process' exclusion
@@ -825,6 +845,10 @@ def get_files(self):
825
845
path_components = ['system' , 'lib' , 'libc' , 'musl' , 'src' , 'sched' ],
826
846
filenames = ['sched_yield.c' ])
827
847
848
+ libc_files += files_in_path (
849
+ path_components = ['system' , 'lib' , 'libc' , 'musl' , 'src' , 'exit' ],
850
+ filenames = ['_Exit.c' ])
851
+
828
852
libc_files += files_in_path (
829
853
path_components = ['system' , 'lib' , 'libc' ],
830
854
filenames = [
@@ -1390,9 +1414,7 @@ def get_files(self):
1390
1414
# including fprintf etc.
1391
1415
exit_files = files_in_path (
1392
1416
path_components = ['system' , 'lib' , 'libc' , 'musl' , 'src' , 'exit' ],
1393
- filenames = ['assert.c' , 'atexit.c' , 'exit.c' ]) + files_in_path (
1394
- path_components = ['system' , 'lib' , 'libc' , 'musl' , 'src' , 'unistd' ],
1395
- filenames = ['_exit.c' ])
1417
+ filenames = ['assert.c' , 'atexit.c' , 'exit.c' ])
1396
1418
return base_files + time_files + exit_files
1397
1419
1398
1420
0 commit comments