Skip to content

Conversation

@xal-0
Copy link
Member

@xal-0 xal-0 commented Nov 17, 2025

We have been using ld64's -all_load as the mac equivalent to --whole-archive, but -force_load does something closer to what we want. From the ld64 man page:

-all_load
        Loads all members of static archive libraries.
-force_load path_to_archive
        Loads all members of the specified static archive library.  Note:
        -all_load forces all members of all archives to be loaded.  This
        option allows you to target a specific archive.

When we link libjulia-internal.dylib and libjulia-codegen.dylib with -all_load, we pull in more of the static LLVM support libraries than we need.

Before:

5.1M	usr/lib/libjulia-internal.1.14.0.dylib
2.1M	usr/lib/libjulia-codegen.1.14.0.dylib

After:

3.8M	usr/lib/libjulia-internal.1.14.0.dylib
2.1M	usr/lib/libjulia-codegen.1.14.0.dylib

We have been using ld64's `-all_load` as the mac equivalent to
`--whole-archive`, but `-force_load` does something closer to what we want.
From the ld64 man page:
```
-all_load
        Loads all members of static archive libraries.
-force_load path_to_archive
        Loads all members of the specified static archive library.  Note:
        -all_load forces all members of all archives to be loaded.  This
        option allows you to target a specific archive.
```

When we link `libjulia-internal.dylib` and `libjulia-codegen.dylib` with
`-all_load`, we pull in more of the static LLVM support libraries than we need.

Before:
```
5.1M	usr/lib/libjulia-internal.1.14.0.dylib
2.1M	usr/lib/libjulia-codegen.1.14.0.dylib
```

After:
```
3.8M	usr/lib/libjulia-internal.1.14.0.dylib
2.1M	usr/lib/libjulia-codegen.1.14.0.dylib
```
@xal-0 xal-0 added building Build system, or building Julia or its dependencies system:mac Affects only macOS labels Nov 17, 2025
@Keno
Copy link
Member

Keno commented Nov 17, 2025

I feel like WHOLE_ARCHIVE is a little misleading then, because it sounds like it applies to all the following archives, not just the next one. Maybe we could have (call whole_archive lib) that expands to -whole-archive lib -no-whole-archive on other platforms?

@xal-0
Copy link
Member Author

xal-0 commented Nov 17, 2025

I'm not opposed to doing that for the makefiles. What do you think about touching Base.Linking.WHOLE_ARCHIVE? JuliaC.jl only puts one $WHOLE_ARCHIVE; PackageCompiler.jl hardcodes -all_load.

@Keno
Copy link
Member

Keno commented Nov 18, 2025

I think we can leave that as is and define a new whole_archive(lib) = `-Wl,-whole-archive $lib -Wl,-no-whole-archive` function on the julia side as well.

@xal-0 xal-0 merged commit cd2dc91 into JuliaLang:master Nov 18, 2025
8 checks passed
@xal-0 xal-0 deleted the ld64-force-load branch November 18, 2025 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

building Build system, or building Julia or its dependencies system:mac Affects only macOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants