Skip to content

Commit bceab81

Browse files
authored
Build musl 'exit' files by default. NFC (#26083)
Previously we were by default excluding the `exit` directory and then including and explict subset. Now we include the whole directory and exclude the files we don't want. The overall file list should be the same before and after. Hence NFC.
1 parent dc878db commit bceab81

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

tools/system_libs.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ def build_objects(self, build_dir):
492492
batches = {}
493493
commands = []
494494
objects = set()
495+
objects_lowercase = set()
495496
cflags = self.get_cflags()
496497
for src in self.get_files():
497498
ext = utils.suffix(src)
@@ -509,17 +510,17 @@ def build_objects(self, build_dir):
509510
cmd += cflags
510511
cmd = self.customize_build_cmd(cmd, src)
511512

512-
object_basename = utils.unsuffixed_basename(src).lower()
513+
object_basename = utils.unsuffixed_basename(src)
513514
o = os.path.join(build_dir, object_basename + '.o')
514-
if o in objects:
515+
if o.lower() in objects_lowercase:
515516
# If we have seen a file with the same name before, we need a separate
516517
# command to compile this file with a custom unique output object
517518
# filename, as batch compile doesn't allow such customization.
518519
#
519520
# This is needed to handle, for example, _exit.o and _Exit.o.
520521
object_uuid = 0
521522
# Find a unique basename
522-
while o in objects:
523+
while o.lower() in objects_lowercase:
523524
object_uuid += 1
524525
o = os.path.join(build_dir, f'{object_basename}__{object_uuid}.o')
525526
commands.append(cmd + [src, '-o', o])
@@ -529,11 +530,10 @@ def build_objects(self, build_dir):
529530
src = os.path.relpath(src, build_dir)
530531
src = utils.normalize_path(src)
531532
batches.setdefault(tuple(cmd), []).append(src)
532-
# No -o in command, use original file name.
533-
o = os.path.join(build_dir, utils.unsuffixed_basename(src) + '.o')
534533
else:
535534
commands.append(cmd + [src, '-o', o])
536535
objects.add(o)
536+
objects_lowercase.add(o.lower())
537537

538538
if batch_inputs:
539539
# Choose a chunk size that is large enough to avoid too many subprocesses
@@ -1144,7 +1144,7 @@ def get_files(self):
11441144
# musl modules
11451145
ignore = [
11461146
'ipc', 'passwd', 'signal', 'sched', 'time', 'linux',
1147-
'aio', 'exit', 'legacy', 'mq', 'setjmp',
1147+
'aio', 'legacy', 'mq', 'setjmp',
11481148
'ldso', 'malloc',
11491149
]
11501150

@@ -1158,11 +1158,13 @@ def get_files(self):
11581158
'getgrouplist.c', 'initgroups.c', 'wordexp.c', 'timer_create.c',
11591159
'getauxval.c',
11601160
'lookup_name.c',
1161-
# 'process' exclusion
1161+
# 'process' exclusions
11621162
'fork.c', 'vfork.c', 'posix_spawn.c', 'posix_spawnp.c', 'execve.c', 'waitid.c', 'system.c',
11631163
'_Fork.c',
1164-
# 'env' exclusion
1164+
# 'env' exclusions
11651165
'__reset_tls.c', '__init_tls.c', '__libc_start_main.c',
1166+
# 'exit' exclusions
1167+
'assert.c', 'exit.c',
11661168
]
11671169

11681170
ignore += LIBC_SOCKETS
@@ -1312,10 +1314,6 @@ def get_files(self):
13121314
path='system/lib/libc/musl/src/sched',
13131315
filenames=['sched_yield.c'])
13141316

1315-
libc_files += files_in_path(
1316-
path='system/lib/libc/musl/src/exit',
1317-
filenames=['abort.c', '_Exit.c', 'atexit.c', 'at_quick_exit.c', 'quick_exit.c'])
1318-
13191317
libc_files += files_in_path(
13201318
path='system/lib/libc/musl/src/ldso',
13211319
filenames=['dladdr.c', 'dlerror.c', 'dlsym.c', 'dlclose.c'])

0 commit comments

Comments
 (0)