Skip to content

compiler-rt: omit symbols that are already provided by dynamic libc #11883

@andrewrk

Description

@andrewrk

On macOS, libSystem contains compiler-rt already, which has many identical symbols to Zig's compiler-rt:

___atomic_compare_exchange, ___atomic_compare_exchange_1,
___atomic_compare_exchange_2, ___atomic_compare_exchange_4,
___atomic_compare_exchange_8, ___atomic_exchange, ___atomic_exchange_1,
___atomic_exchange_2, ___atomic_exchange_4, ___atomic_exchange_8,
___atomic_fetch_add_1, ___atomic_fetch_add_2, ___atomic_fetch_add_4,
___atomic_fetch_add_8, ___atomic_fetch_and_1, ___atomic_fetch_and_2,
___atomic_fetch_and_4, ___atomic_fetch_and_8, ___atomic_fetch_or_1,
___atomic_fetch_or_2, ___atomic_fetch_or_4, ___atomic_fetch_or_8,
___atomic_fetch_sub_1, ___atomic_fetch_sub_2, ___atomic_fetch_sub_4,
___atomic_fetch_sub_8, ___atomic_fetch_xor_1, ___atomic_fetch_xor_2,
___atomic_fetch_xor_4, ___atomic_fetch_xor_8, ___atomic_load,
___atomic_load_1, ___atomic_load_2, ___atomic_load_4, ___atomic_load_8,
___atomic_store, ___atomic_store_1, ___atomic_store_2, ___atomic_store_4,
___atomic_store_8, ___chkstk_darwin, ___clear_cache, ___clzti2,
___divti3, ___enable_execute_stack, ___extendhfsf2, ___fixdfti,
___fixsfti, ___fixunsdfti, ___fixunssfti, ___floattidf, ___floattisf,
___floatuntidf, ___floatuntisf, ___gcc_personality_v0, ___gnu_f2h_ieee,
___gnu_h2f_ieee, ___modti3, ___muldc3, ___mulsc3, ___powidf2,
___powisf2, ___truncdfhf2, ___truncsfhf2, ___udivmodti4, ___udivti3,
___umodti3, _atomic_flag_clear, _atomic_flag_clear_explicit,
_atomic_flag_test_and_set, _atomic_flag_test_and_set_explicit,
_atomic_signal_fence, _atomic_thread_fence ]

As an optimization, our compiler-rt can check if generating a given symbol would be redundant, and avoid calling @export for that symbol. This will make 2 small improvements:

  • Faster compiler-rt build from cold cache (fewer functions to optimize)
  • Faster link against compiler-rt (since the static archive will be smaller)

Similar issue: #11884

Metadata

Metadata

Assignees

No one assigned

    Labels

    compiler-rtcontributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.enhancementSolving this issue will likely involve adding new logic or components to the codebase.optimizationos-macosmacOS

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions