diff --git a/src/install_files.h b/src/install_files.h index a76ff42a9f..8c81a3fc80 100644 --- a/src/install_files.h +++ b/src/install_files.h @@ -80,7 +80,6 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/crypt/crypt.c", "musl/src/crypt/crypt_blowfish.c", "musl/src/crypt/crypt_des.c", -"musl/src/crypt/crypt_des.h", "musl/src/crypt/crypt_md5.c", "musl/src/crypt/crypt_r.c", "musl/src/crypt/crypt_sha256.c", @@ -90,7 +89,6 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/ctype/__ctype_get_mb_cur_max.c", "musl/src/ctype/__ctype_tolower_loc.c", "musl/src/ctype/__ctype_toupper_loc.c", -"musl/src/ctype/alpha.h", "musl/src/ctype/isalnum.c", "musl/src/ctype/isalpha.c", "musl/src/ctype/isascii.c", @@ -117,8 +115,6 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/ctype/iswupper.c", "musl/src/ctype/iswxdigit.c", "musl/src/ctype/isxdigit.c", -"musl/src/ctype/nonspacing.h", -"musl/src/ctype/punct.h", "musl/src/ctype/toascii.c", "musl/src/ctype/tolower.c", "musl/src/ctype/toupper.c", @@ -126,8 +122,6 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/ctype/wcswidth.c", "musl/src/ctype/wctrans.c", "musl/src/ctype/wcwidth.c", -"musl/src/ctype/wide.h", -"musl/src/dirent/__dirent.h", "musl/src/dirent/alphasort.c", "musl/src/dirent/closedir.c", "musl/src/dirent/dirfd.c", @@ -152,7 +146,6 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/env/setenv.c", "musl/src/env/unsetenv.c", "musl/src/errno/__errno_location.c", -"musl/src/errno/__strerror.h", "musl/src/errno/strerror.c", "musl/src/exit/_Exit.c", "musl/src/exit/abort.c", @@ -196,55 +189,18 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/fenv/sh/fenv.S", "musl/src/fenv/x32/fenv.s", "musl/src/fenv/x86_64/fenv.s", -"musl/src/include/arpa/inet.h", -"musl/src/include/crypt.h", -"musl/src/include/errno.h", -"musl/src/include/features.h", -"musl/src/include/langinfo.h", -"musl/src/include/pthread.h", -"musl/src/include/resolv.h", -"musl/src/include/signal.h", -"musl/src/include/stdio.h", -"musl/src/include/stdlib.h", -"musl/src/include/string.h", -"musl/src/include/sys/auxv.h", -"musl/src/include/sys/membarrier.h", -"musl/src/include/sys/mman.h", -"musl/src/include/sys/sysinfo.h", -"musl/src/include/sys/time.h", -"musl/src/include/time.h", -"musl/src/include/unistd.h", -"musl/src/include/wchar.h", -"musl/src/internal/atomic.h", -"musl/src/internal/complex_impl.h", "musl/src/internal/defsysinfo.c", -"musl/src/internal/dynlink.h", -"musl/src/internal/fdpic_crt.h", "musl/src/internal/floatscan.c", -"musl/src/internal/floatscan.h", -"musl/src/internal/futex.h", "musl/src/internal/i386/defsysinfo.s", "musl/src/internal/intscan.c", -"musl/src/internal/intscan.h", -"musl/src/internal/ksigaction.h", "musl/src/internal/libc.c", -"musl/src/internal/libc.h", -"musl/src/internal/libm.h", -"musl/src/internal/locale_impl.h", -"musl/src/internal/lock.h", -"musl/src/internal/malloc_impl.h", "musl/src/internal/procfdname.c", -"musl/src/internal/pthread_impl.h", "musl/src/internal/sh/__shcall.c", "musl/src/internal/shgetc.c", -"musl/src/internal/shgetc.h", -"musl/src/internal/stdio_impl.h", -"musl/src/internal/syscall.h", "musl/src/internal/syscall_ret.c", "musl/src/internal/vdso.c", "musl/src/internal/version.c", "musl/src/ipc/ftok.c", -"musl/src/ipc/ipc.h", "musl/src/ipc/msgctl.c", "musl/src/ipc/msgget.c", "musl/src/ipc/msgrcv.c", @@ -261,6 +217,7 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/ldso/aarch64/dlsym.s", "musl/src/ldso/aarch64/tlsdesc.s", "musl/src/ldso/arm/dlsym.s", +"musl/src/ldso/arm/dlsym_time64.S", "musl/src/ldso/arm/find_exidx.c", "musl/src/ldso/arm/tlsdesc.S", "musl/src/ldso/dl_iterate_phdr.c", @@ -271,18 +228,26 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/ldso/dlopen.c", "musl/src/ldso/dlsym.c", "musl/src/ldso/i386/dlsym.s", +"musl/src/ldso/i386/dlsym_time64.S", "musl/src/ldso/i386/tlsdesc.s", "musl/src/ldso/m68k/dlsym.s", +"musl/src/ldso/m68k/dlsym_time64.S", "musl/src/ldso/microblaze/dlsym.s", +"musl/src/ldso/microblaze/dlsym_time64.S", "musl/src/ldso/mips/dlsym.s", +"musl/src/ldso/mips/dlsym_time64.S", "musl/src/ldso/mips64/dlsym.s", "musl/src/ldso/mipsn32/dlsym.s", +"musl/src/ldso/mipsn32/dlsym_time64.S", "musl/src/ldso/or1k/dlsym.s", +"musl/src/ldso/or1k/dlsym_time64.S", "musl/src/ldso/powerpc/dlsym.s", +"musl/src/ldso/powerpc/dlsym_time64.S", "musl/src/ldso/powerpc64/dlsym.s", "musl/src/ldso/riscv64/dlsym.s", "musl/src/ldso/s390x/dlsym.s", "musl/src/ldso/sh/dlsym.s", +"musl/src/ldso/sh/dlsym_time64.S", "musl/src/ldso/tlsdesc.c", "musl/src/ldso/x32/dlsym.s", "musl/src/ldso/x86_64/dlsym.s", @@ -369,30 +334,21 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/linux/xattr.c", "musl/src/locale/__lctrans.c", "musl/src/locale/__mo_lookup.c", -"musl/src/locale/big5.h", "musl/src/locale/bind_textdomain_codeset.c", "musl/src/locale/c_locale.c", "musl/src/locale/catclose.c", "musl/src/locale/catgets.c", "musl/src/locale/catopen.c", -"musl/src/locale/codepages.h", "musl/src/locale/dcngettext.c", "musl/src/locale/duplocale.c", "musl/src/locale/freelocale.c", -"musl/src/locale/gb18030.h", -"musl/src/locale/hkscs.h", "musl/src/locale/iconv.c", "musl/src/locale/iconv_close.c", -"musl/src/locale/jis0208.h", -"musl/src/locale/ksc.h", "musl/src/locale/langinfo.c", -"musl/src/locale/legacychars.h", "musl/src/locale/locale_map.c", "musl/src/locale/localeconv.c", "musl/src/locale/newlocale.c", "musl/src/locale/pleval.c", -"musl/src/locale/pleval.h", -"musl/src/locale/revjis.h", "musl/src/locale/setlocale.c", "musl/src/locale/strcoll.c", "musl/src/locale/strfmon.c", @@ -401,7 +357,6 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/locale/uselocale.c", "musl/src/locale/wcscoll.c", "musl/src/locale/wcsxfrm.c", -"musl/src/malloc/DESIGN", "musl/src/malloc/aligned_alloc.c", "musl/src/malloc/expand_heap.c", "musl/src/malloc/lite_malloc.c", @@ -418,7 +373,6 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/math/__fpclassifyf.c", "musl/src/math/__fpclassifyl.c", "musl/src/math/__invtrigl.c", -"musl/src/math/__invtrigl.h", "musl/src/math/__math_divzero.c", "musl/src/math/__math_divzerof.c", "musl/src/math/__math_invalid.c", @@ -525,10 +479,8 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/math/exp2.c", "musl/src/math/exp2f.c", "musl/src/math/exp2f_data.c", -"musl/src/math/exp2f_data.h", "musl/src/math/exp2l.c", "musl/src/math/exp_data.c", -"musl/src/math/exp_data.h", "musl/src/math/expf.c", "musl/src/math/expl.c", "musl/src/math/expm1.c", @@ -579,14 +531,9 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/math/i386/ceil.s", "musl/src/math/i386/ceilf.s", "musl/src/math/i386/ceill.s", -"musl/src/math/i386/exp.s", -"musl/src/math/i386/exp2.s", -"musl/src/math/i386/exp2f.s", "musl/src/math/i386/exp2l.s", -"musl/src/math/i386/expf.s", +"musl/src/math/i386/exp_ld.s", "musl/src/math/i386/expl.s", -"musl/src/math/i386/expm1.s", -"musl/src/math/i386/expm1f.s", "musl/src/math/i386/expm1l.s", "musl/src/math/i386/fabs.s", "musl/src/math/i386/fabsf.s", @@ -673,19 +620,15 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/math/log1pl.c", "musl/src/math/log2.c", "musl/src/math/log2_data.c", -"musl/src/math/log2_data.h", "musl/src/math/log2f.c", "musl/src/math/log2f_data.c", -"musl/src/math/log2f_data.h", "musl/src/math/log2l.c", "musl/src/math/log_data.c", -"musl/src/math/log_data.h", "musl/src/math/logb.c", "musl/src/math/logbf.c", "musl/src/math/logbl.c", "musl/src/math/logf.c", "musl/src/math/logf_data.c", -"musl/src/math/logf_data.h", "musl/src/math/logl.c", "musl/src/math/lrint.c", "musl/src/math/lrintf.c", @@ -693,6 +636,10 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/math/lround.c", "musl/src/math/lroundf.c", "musl/src/math/lroundl.c", +"musl/src/math/mips/fabs.c", +"musl/src/math/mips/fabsf.c", +"musl/src/math/mips/sqrt.c", +"musl/src/math/mips/sqrtf.c", "musl/src/math/modf.c", "musl/src/math/modff.c", "musl/src/math/modfl.c", @@ -710,7 +657,6 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/math/nexttowardl.c", "musl/src/math/pow.c", "musl/src/math/pow_data.c", -"musl/src/math/pow_data.h", "musl/src/math/powerpc/fabs.c", "musl/src/math/powerpc/fabsf.c", "musl/src/math/powerpc/fma.c", @@ -741,7 +687,6 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/math/powerpc64/truncf.c", "musl/src/math/powf.c", "musl/src/math/powf_data.c", -"musl/src/math/powf_data.h", "musl/src/math/powl.c", "musl/src/math/remainder.c", "musl/src/math/remainderf.c", @@ -958,7 +903,6 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/multibyte/c16rtomb.c", "musl/src/multibyte/c32rtomb.c", "musl/src/multibyte/internal.c", -"musl/src/multibyte/internal.h", "musl/src/multibyte/mblen.c", "musl/src/multibyte/mbrlen.c", "musl/src/multibyte/mbrtoc16.c", @@ -1021,12 +965,10 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/network/inet_ntop.c", "musl/src/network/inet_pton.c", "musl/src/network/listen.c", -"musl/src/network/lookup.h", "musl/src/network/lookup_ipliteral.c", "musl/src/network/lookup_name.c", "musl/src/network/lookup_serv.c", "musl/src/network/netlink.c", -"musl/src/network/netlink.h", "musl/src/network/netname.c", "musl/src/network/ns_parse.c", "musl/src/network/ntohl.c", @@ -1070,12 +1012,10 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/passwd/getspnam.c", "musl/src/passwd/getspnam_r.c", "musl/src/passwd/lckpwdf.c", -"musl/src/passwd/nscd.h", "musl/src/passwd/nscd_query.c", "musl/src/passwd/putgrent.c", "musl/src/passwd/putpwent.c", "musl/src/passwd/putspent.c", -"musl/src/passwd/pwf.h", "musl/src/prng/__rand48_step.c", "musl/src/prng/__seed48.c", "musl/src/prng/drand48.c", @@ -1083,7 +1023,6 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/prng/lrand48.c", "musl/src/prng/mrand48.c", "musl/src/prng/rand.c", -"musl/src/prng/rand48.h", "musl/src/prng/rand_r.c", "musl/src/prng/random.c", "musl/src/prng/seed48.c", @@ -1095,7 +1034,6 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/process/execv.c", "musl/src/process/execve.c", "musl/src/process/execvp.c", -"musl/src/process/fdop.h", "musl/src/process/fexecve.c", "musl/src/process/fork.c", "musl/src/process/i386/vfork.s", @@ -1134,7 +1072,6 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/regex/regerror.c", "musl/src/regex/regexec.c", "musl/src/regex/tre-mem.c", -"musl/src/regex/tre.h", "musl/src/sched/affinity.c", "musl/src/sched/sched_cpucount.c", "musl/src/sched/sched_get_priority_max.c", @@ -1152,7 +1089,6 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/search/tdestroy.c", "musl/src/search/tfind.c", "musl/src/search/tsearch.c", -"musl/src/search/tsearch.h", "musl/src/search/twalk.c", "musl/src/select/poll.c", "musl/src/select/pselect.c", @@ -1335,7 +1271,6 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/stdio/fwrite.c", "musl/src/stdio/fwscanf.c", "musl/src/stdio/getc.c", -"musl/src/stdio/getc.h", "musl/src/stdio/getc_unlocked.c", "musl/src/stdio/getchar.c", "musl/src/stdio/getchar_unlocked.c", @@ -1354,7 +1289,6 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/stdio/popen.c", "musl/src/stdio/printf.c", "musl/src/stdio/putc.c", -"musl/src/stdio/putc.h", "musl/src/stdio/putc_unlocked.c", "musl/src/stdio/putchar.c", "musl/src/stdio/putchar_unlocked.c", @@ -1746,7 +1680,6 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/time/strftime.c", "musl/src/time/strptime.c", "musl/src/time/time.c", -"musl/src/time/time_impl.h", "musl/src/time/timegm.c", "musl/src/time/timer_create.c", "musl/src/time/timer_delete.c", @@ -1843,4 +1776,69 @@ static const char *ZIG_MUSL_SRC_FILES[] = { "musl/src/unistd/writev.c", "musl/src/unistd/x32/lseek.c", }; +static const char *ZIG_MUSL_COMPAT_TIME32_FILES[] = { +"musl/compat/time32/__xstat.c", +"musl/compat/time32/adjtime32.c", +"musl/compat/time32/adjtimex_time32.c", +"musl/compat/time32/aio_suspend_time32.c", +"musl/compat/time32/clock_adjtime32.c", +"musl/compat/time32/clock_getres_time32.c", +"musl/compat/time32/clock_gettime32.c", +"musl/compat/time32/clock_nanosleep_time32.c", +"musl/compat/time32/clock_settime32.c", +"musl/compat/time32/cnd_timedwait_time32.c", +"musl/compat/time32/ctime32.c", +"musl/compat/time32/ctime32_r.c", +"musl/compat/time32/difftime32.c", +"musl/compat/time32/fstat_time32.c", +"musl/compat/time32/fstatat_time32.c", +"musl/compat/time32/ftime32.c", +"musl/compat/time32/futimens_time32.c", +"musl/compat/time32/futimes_time32.c", +"musl/compat/time32/futimesat_time32.c", +"musl/compat/time32/getitimer_time32.c", +"musl/compat/time32/getrusage_time32.c", +"musl/compat/time32/gettimeofday_time32.c", +"musl/compat/time32/gmtime32.c", +"musl/compat/time32/gmtime32_r.c", +"musl/compat/time32/localtime32.c", +"musl/compat/time32/localtime32_r.c", +"musl/compat/time32/lstat_time32.c", +"musl/compat/time32/lutimes_time32.c", +"musl/compat/time32/mktime32.c", +"musl/compat/time32/mq_timedreceive_time32.c", +"musl/compat/time32/mq_timedsend_time32.c", +"musl/compat/time32/mtx_timedlock_time32.c", +"musl/compat/time32/nanosleep_time32.c", +"musl/compat/time32/ppoll_time32.c", +"musl/compat/time32/pselect_time32.c", +"musl/compat/time32/pthread_cond_timedwait_time32.c", +"musl/compat/time32/pthread_mutex_timedlock_time32.c", +"musl/compat/time32/pthread_rwlock_timedrdlock_time32.c", +"musl/compat/time32/pthread_rwlock_timedwrlock_time32.c", +"musl/compat/time32/pthread_timedjoin_np_time32.c", +"musl/compat/time32/recvmmsg_time32.c", +"musl/compat/time32/sched_rr_get_interval_time32.c", +"musl/compat/time32/select_time32.c", +"musl/compat/time32/sem_timedwait_time32.c", +"musl/compat/time32/semtimedop_time32.c", +"musl/compat/time32/setitimer_time32.c", +"musl/compat/time32/settimeofday_time32.c", +"musl/compat/time32/sigtimedwait_time32.c", +"musl/compat/time32/stat_time32.c", +"musl/compat/time32/stime32.c", +"musl/compat/time32/thrd_sleep_time32.c", +"musl/compat/time32/time32.c", +"musl/compat/time32/time32gm.c", +"musl/compat/time32/timer_gettime32.c", +"musl/compat/time32/timer_settime32.c", +"musl/compat/time32/timerfd_gettime32.c", +"musl/compat/time32/timerfd_settime32.c", +"musl/compat/time32/timespec_get_time32.c", +"musl/compat/time32/utime_time32.c", +"musl/compat/time32/utimensat_time32.c", +"musl/compat/time32/utimes_time32.c", +"musl/compat/time32/wait3_time32.c", +"musl/compat/time32/wait4_time32.c", +}; #endif diff --git a/src/link.cpp b/src/link.cpp index eba12b924a..5b6d3a4fdb 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -983,44 +983,59 @@ static bool is_musl_arch_name(const char *name) { return false; } +enum MuslSrc { + MuslSrcAsm, + MuslSrcNormal, + MuslSrcO3, +}; + +static void add_musl_src_file(HashMap &source_table, + const char *file_path) +{ + Buf *src_file = buf_create_from_str(file_path); + + MuslSrc src_kind; + if (buf_ends_with_str(src_file, ".c")) { + bool want_O3 = buf_starts_with_str(src_file, "musl/src/malloc/") || + buf_starts_with_str(src_file, "musl/src/string/") || + buf_starts_with_str(src_file, "musl/src/internal/"); + src_kind = want_O3 ? MuslSrcO3 : MuslSrcNormal; + } else if (buf_ends_with_str(src_file, ".s") || buf_ends_with_str(src_file, ".S")) { + src_kind = MuslSrcAsm; + } else { + zig_unreachable(); + } + if (ZIG_OS_SEP_CHAR != '/') { + buf_replace(src_file, '/', ZIG_OS_SEP_CHAR); + } + source_table.put_unique(src_file, src_kind); +} + static const char *build_musl(CodeGen *parent, Stage2ProgressNode *progress_node) { CodeGen *child_gen = create_child_codegen(parent, nullptr, OutTypeLib, nullptr, "c", progress_node); // When there is a src//foo.* then it should substitute for src/foo.* // Even a .s file can substitute for a .c file. - enum MuslSrc { - MuslSrcAsm, - MuslSrcNormal, - MuslSrcO3, - }; - const char *target_musl_arch_name = target_arch_musl_name(parent->zig_target->arch); HashMap source_table = {}; - source_table.init(1800); + source_table.init(2000); for (size_t i = 0; i < array_length(ZIG_MUSL_SRC_FILES); i += 1) { - Buf *src_file = buf_create_from_str(ZIG_MUSL_SRC_FILES[i]); - - MuslSrc src_kind; - if (buf_ends_with_str(src_file, ".c")) { - assert(buf_starts_with_str(src_file, "musl/src/")); - bool want_O3 = buf_starts_with_str(src_file, "musl/src/malloc/") || - buf_starts_with_str(src_file, "musl/src/string/") || - buf_starts_with_str(src_file, "musl/src/internal/"); - src_kind = want_O3 ? MuslSrcO3 : MuslSrcNormal; - } else if (buf_ends_with_str(src_file, ".s") || buf_ends_with_str(src_file, ".S")) { - src_kind = MuslSrcAsm; - } else { - continue; - } - if (ZIG_OS_SEP_CHAR != '/') { - buf_replace(src_file, '/', ZIG_OS_SEP_CHAR); - } - source_table.put_unique(src_file, src_kind); + add_musl_src_file(source_table, ZIG_MUSL_SRC_FILES[i]); } + static const char *time32_compat_arch_list[] = {"arm", "i386", "mips", "powerpc"}; + for (size_t arch_i = 0; arch_i < array_length(time32_compat_arch_list); arch_i += 1) { + if (strcmp(target_musl_arch_name, time32_compat_arch_list[arch_i]) == 0) { + for (size_t i = 0; i < array_length(ZIG_MUSL_COMPAT_TIME32_FILES); i += 1) { + add_musl_src_file(source_table, ZIG_MUSL_COMPAT_TIME32_FILES[i]); + } + } + } + + ZigList c_source_files = {0}; Buf dirname = BUF_INIT;