Skip to content

Conversation

topolarity
Copy link
Member

@topolarity topolarity commented Feb 24, 2025

Inspired by a bug I hit on MinGW recently with weak symbol resolution. I'm not sure why we started using these in 70000ac, since I believe we should be able to lookup these symbols just fine in our jl_exe_handle as long as it was linked / compiled with -rdynamic

Migrating away from weak symbols seems a good idea, given their uneven implementation across platforms.

@topolarity topolarity requested a review from Keno February 24, 2025 19:38
@topolarity topolarity changed the title runtime: Remove usages of weak symbols Remove usages of weak symbols Feb 25, 2025
Copy link
Member

@Keno Keno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, NAK. This is for linking everything statically into one image and for when the dynamic linker is unavailable.

@topolarity topolarity force-pushed the ct/rm-weak-symbol branch 2 times, most recently from 661d228 to 39d55dc Compare February 26, 2025 00:34
@topolarity
Copy link
Member Author

Re-worked to support statically linking sysimage again (untested)

We don't have official support for this in the Makefile, but it should be just a matter of filtering out the null_sysimage.o when linking (or move it to a static lib, where the extra definition will be automatically dropped by the linker)

Inspired by a bug I hit on MinGW recently with weak symbol resolution.
I'm not sure why we started using these in
70000ac. We should be able to lookup
these symbols just fine in our `jl_exe_handle` as long as it was
linked / compiled with `-rdynamic`

Migrating away from weak symbols seems a good idea, given their uneven
implementation across platforms.
Copy link
Member

@Keno Keno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine. It makes the build process a little less automagic, but this is deep arcana anyway, and I don't see any major downside to having to be explicit.

@topolarity topolarity merged commit 4a6ada6 into JuliaLang:master Feb 27, 2025
7 checks passed
@topolarity topolarity deleted the ct/rm-weak-symbol branch February 27, 2025 00:20
Keno pushed a commit that referenced this pull request Feb 28, 2025
Introduce `jl_image_buf_t` to represent the in-memory details of an
unparsed system image and clean-up several global variables and split
loading logic in staticdata.c so that we get (almost) everything we need
from the sysimage handle at once.

This allows sysimage loading to be separated into three phases:
  1. Lookup the raw sysimage buffer as a `jl_image_buf_t`
2. For .so sysimages, parse the sysimage and initialize JIT targets,
etc.
  3. Finally load the sysimage into a `jl_image_t`

Care was taken to preserve the existing behavior of calling
`jl_set_sysimg_so` to configure the sysimage before initializing Julia,
although this is likely to be next on the chopping block in a follow-up.

Dependent on #57523.
@KristofferC KristofferC added the backport 1.12 Change should be backported to release-1.12 label May 5, 2025
KristofferC pushed a commit that referenced this pull request May 5, 2025
Inspired by a bug I hit on MinGW recently with weak symbol resolution.
I'm not sure why we started using these in
70000ac, since I believe we should be
able to lookup these symbols just fine in our `jl_exe_handle` as long as
it was linked / compiled with `-rdynamic`

Migrating away from weak symbols seems a good idea, given their uneven
implementation across platforms.

(cherry picked from commit 4a6ada6)
@KristofferC KristofferC mentioned this pull request May 5, 2025
53 tasks
gbaraldi added a commit that referenced this pull request May 5, 2025
Introduce `jl_image_buf_t` to represent the in-memory details of an
unparsed system image and clean-up several global variables and split
loading logic in staticdata.c so that we get (almost) everything we need
from the sysimage handle at once.

This allows sysimage loading to be separated into three phases:
  1. Lookup the raw sysimage buffer as a `jl_image_buf_t`
2. For .so sysimages, parse the sysimage and initialize JIT targets,
etc.
  3. Finally load the sysimage into a `jl_image_t`

Care was taken to preserve the existing behavior of calling
`jl_set_sysimg_so` to configure the sysimage before initializing Julia,
although this is likely to be next on the chopping block in a follow-up.

Dependent on #57523.
@KristofferC KristofferC removed the backport 1.12 Change should be backported to release-1.12 label May 9, 2025
xal-0 pushed a commit to xal-0/julia that referenced this pull request Aug 18, 2025
Introduce `jl_image_buf_t` to represent the in-memory details of an
unparsed system image and clean-up several global variables and split
loading logic in staticdata.c so that we get (almost) everything we need
from the sysimage handle at once.

This allows sysimage loading to be separated into three phases:
  1. Lookup the raw sysimage buffer as a `jl_image_buf_t`
2. For .so sysimages, parse the sysimage and initialize JIT targets,
etc.
  3. Finally load the sysimage into a `jl_image_t`

Care was taken to preserve the existing behavior of calling
`jl_set_sysimg_so` to configure the sysimage before initializing Julia,
although this is likely to be next on the chopping block in a follow-up.

Dependent on JuliaLang#57523.
xal-0 added a commit that referenced this pull request Aug 20, 2025
commit d062060
Author: Sam Schweigel <[email protected]>
Date:   Wed Aug 6 16:35:34 2025 -0700

    System image compression with zstd

    Co-authored-by: Gabriel Baraldi <[email protected]>

    madvise with MADV_WILLNEED before accessing sysimage pages

    MADV_WILLNEED sysimage pages before checksumming or decompressing

    Even without compression, this gives about an 8% improvement in load times.

    Fix using jl_page_size before it is initialized

    Add zstd to ANALYSIS_DEPS now that it is used in staticdata.c

    Fix jl_page_size being uninitialized in jl_prefetch_system_image

    Add --compress-sysimage flag; use zstd-15 when enabled

commit 56a6065
Author: Sam Schweigel <[email protected]>
Date:   Mon Aug 18 13:27:13 2025 -0700

    Janky zstd backport

commit 4b731bb
Author: Cody Tapscott <[email protected]>
Date:   Thu Feb 27 22:20:02 2025 -0500

    staticdata: Refactor sysimage loading (#57542)

    Introduce `jl_image_buf_t` to represent the in-memory details of an
    unparsed system image and clean-up several global variables and split
    loading logic in staticdata.c so that we get (almost) everything we need
    from the sysimage handle at once.

    This allows sysimage loading to be separated into three phases:
      1. Lookup the raw sysimage buffer as a `jl_image_buf_t`
    2. For .so sysimages, parse the sysimage and initialize JIT targets,
    etc.
      3. Finally load the sysimage into a `jl_image_t`

    Care was taken to preserve the existing behavior of calling
    `jl_set_sysimg_so` to configure the sysimage before initializing Julia,
    although this is likely to be next on the chopping block in a follow-up.

    Dependent on #57523.
xal-0 added a commit to xal-0/julia that referenced this pull request Aug 20, 2025
commit d062060
Author: Sam Schweigel <[email protected]>
Date:   Wed Aug 6 16:35:34 2025 -0700

    System image compression with zstd

    Co-authored-by: Gabriel Baraldi <[email protected]>

    madvise with MADV_WILLNEED before accessing sysimage pages

    MADV_WILLNEED sysimage pages before checksumming or decompressing

    Even without compression, this gives about an 8% improvement in load times.

    Fix using jl_page_size before it is initialized

    Add zstd to ANALYSIS_DEPS now that it is used in staticdata.c

    Fix jl_page_size being uninitialized in jl_prefetch_system_image

    Add --compress-sysimage flag; use zstd-15 when enabled

commit 56a6065
Author: Sam Schweigel <[email protected]>
Date:   Mon Aug 18 13:27:13 2025 -0700

    Janky zstd backport

commit 4b731bb
Author: Cody Tapscott <[email protected]>
Date:   Thu Feb 27 22:20:02 2025 -0500

    staticdata: Refactor sysimage loading (JuliaLang#57542)

    Introduce `jl_image_buf_t` to represent the in-memory details of an
    unparsed system image and clean-up several global variables and split
    loading logic in staticdata.c so that we get (almost) everything we need
    from the sysimage handle at once.

    This allows sysimage loading to be separated into three phases:
      1. Lookup the raw sysimage buffer as a `jl_image_buf_t`
    2. For .so sysimages, parse the sysimage and initialize JIT targets,
    etc.
      3. Finally load the sysimage into a `jl_image_t`

    Care was taken to preserve the existing behavior of calling
    `jl_set_sysimg_so` to configure the sysimage before initializing Julia,
    although this is likely to be next on the chopping block in a follow-up.

    Dependent on JuliaLang#57523.
xal-0 pushed a commit to xal-0/julia that referenced this pull request Aug 20, 2025
Introduce `jl_image_buf_t` to represent the in-memory details of an
unparsed system image and clean-up several global variables and split
loading logic in staticdata.c so that we get (almost) everything we need
from the sysimage handle at once.

This allows sysimage loading to be separated into three phases:
  1. Lookup the raw sysimage buffer as a `jl_image_buf_t`
2. For .so sysimages, parse the sysimage and initialize JIT targets,
etc.
  3. Finally load the sysimage into a `jl_image_t`

Care was taken to preserve the existing behavior of calling
`jl_set_sysimg_so` to configure the sysimage before initializing Julia,
although this is likely to be next on the chopping block in a follow-up.

Dependent on JuliaLang#57523.
topolarity added a commit to topolarity/julia that referenced this pull request Aug 20, 2025
Introduce `jl_image_buf_t` to represent the in-memory details of an
unparsed system image and clean-up several global variables and split
loading logic in staticdata.c so that we get (almost) everything we need
from the sysimage handle at once.

This allows sysimage loading to be separated into three phases:
  1. Lookup the raw sysimage buffer as a `jl_image_buf_t`
2. For .so sysimages, parse the sysimage and initialize JIT targets,
etc.
  3. Finally load the sysimage into a `jl_image_t`

Care was taken to preserve the existing behavior of calling
`jl_set_sysimg_so` to configure the sysimage before initializing Julia,
although this is likely to be next on the chopping block in a follow-up.

Dependent on JuliaLang#57523.
topolarity added a commit to xal-0/julia that referenced this pull request Aug 20, 2025
Introduce `jl_image_buf_t` to represent the in-memory details of an
unparsed system image and clean-up several global variables and split
loading logic in staticdata.c so that we get (almost) everything we need
from the sysimage handle at once.

This allows sysimage loading to be separated into three phases:
  1. Lookup the raw sysimage buffer as a `jl_image_buf_t`
2. For .so sysimages, parse the sysimage and initialize JIT targets,
etc.
  3. Finally load the sysimage into a `jl_image_t`

Care was taken to preserve the existing behavior of calling
`jl_set_sysimg_so` to configure the sysimage before initializing Julia,
although this is likely to be next on the chopping block in a follow-up.

Dependent on JuliaLang#57523.
@gbaraldi gbaraldi added the backport 1.11 Change should be backported to release-1.11 label Sep 1, 2025
gbaraldi pushed a commit that referenced this pull request Sep 9, 2025
…ls (#59470)

> Inspired by a bug I hit on MinGW recently with weak symbol resolution.
I'm not sure why we started using these in
70000ac, since I believe we should be
able to lookup these symbols just fine in our `jl_exe_handle` as long as
it was linked / compiled with `-rdynamic`
>
> Migrating away from weak symbols seems a good idea, given their uneven
implementation across platforms.

(cherry picked from commit 4a6ada6)

@gbaraldi asked if this could be backported separately from #59227.

Co-authored-by: Cody Tapscott <[email protected]>
Co-authored-by: Dilum Aluthge <[email protected]>
@DilumAluthge DilumAluthge mentioned this pull request Sep 9, 2025
59 tasks
@DilumAluthge DilumAluthge removed the backport 1.11 Change should be backported to release-1.11 label Sep 9, 2025
@DilumAluthge DilumAluthge added the backport 1.11 Change should be backported to release-1.11 label Sep 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 1.11 Change should be backported to release-1.11
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants