Skip to content

contrib: add optimized Windows builds and fix Linux/macOS regressions - #63214

Open
maleadt wants to merge 8 commits into
masterfrom
tb/opt-windows
Open

maleadt wants to merge 8 commits into
masterfrom
tb/opt-windows

Conversation

@maleadt

@maleadt maleadt commented Sep 16, 2026

Copy link
Copy Markdown
Member

Enable PGO and ThinLTO builds on Windows x86-64, preserving the existing export policy, caller linker flags, and full debug information.

Also fix issues in existing optimized builds:

  • Disable ICF to preserve observable function-pointer identity.
  • Limit ThinLTO concurrency on Linux i686 to avoid exhausting the linker’s address space.
  • Prevent inlining of the task-switch helper whose unwind directives break suspended-task profiling on macOS AArch64.

@maleadt maleadt added performance Must go faster building Build system, or building Julia or its dependencies system:windows Affects only Windows labels Sep 16, 2026
Disable identical code folding in BOLT and omit the extra linker ICF flag.
Function addresses can be observed through dynamic lookup and used as
identifiers, which even safe BOLT folding cannot account for across library
boundaries.

Assisted-by: Codex (GPT-6)
MSYS2 excludes CMAKE_INSTALL_PREFIX from argument conversion, but LLVM's
staged prefix is absolute. Convert it explicitly on Windows hosts so
native CMake installs into the staging tree; Unix hosts retain Unix paths,
including when cross-compiling for Windows. Create the staged DLL directory
before copying libLLVM so cp cannot create a file named bin.

Assisted-by: Codex (GPT-6)
Keep jl_win_restore_page externally visible and marked used because its
assembly reference is invisible to ThinLTO. Remove the .text switch from
`CFI_NORETURN`: .seh_handler does not change sections, and switching away
from a function section separates the remaining instructions from their
prologue. This fixes the task-switch trap and the crash while emitting
variable debug locations, allowing full debug information.

Assisted-by: Codex (GPT-6)
The loader forwards runtime entry points, but its import library must
omit them so libjulia-internal does not resolve its own calls through the
loader. Generate it with dlltool from a filtered export definition because
objcopy cannot rewrite lld's import-library format. Match undecorated names
on both Windows architectures, preserve data and codegen exports, and stop
if preprocessing the runtime list fails.

Assisted-by: Codex (GPT-6)
Translate the runtime export map into a COFF export definition when using
lld. Discover exports from selected archive members before filtering,
preserving explicit exports, data exports and the exclusion of unused
members. Keep Windows visibility under linker control so Clang cannot
suppress symbols selected by the map, and annotate the runtime declarations
used across the codegen DLL boundary with `JL_DLLEXPORT`.

Assisted-by: Codex (GPT-6)
Use Clang and lld's MinGW driver for PGO and ThinLTO, applying the existing
export map through a COFF definition. Separate added compiler-driver flags
from the caller's linker flags and supply the profile runtime explicitly
to Julia's direct Windows links. Keep full debug information; BOLT remains
disabled on Windows because it cannot rewrite PE/COFF.

Install the support and compression DLLs beside the stage-0 tools, skip the
ELF constructor-section fixup, and append each stage's DLL directory to
PATH. Convert LLVM_PROFILE_FILE to a native Windows path while leaving
compiler arguments for MSYS2 to convert. Platform hooks preserve the
existing non-Windows commands.

Assisted-by: Codex (GPT-6)
Concurrent ThinLTO backends exhaust the 32-bit linker's address space when
linking PGO-trained libLLVM on hosts with many cores. Each backend holds a
module and the PGO profile, so make their concurrency configurable through
LTO_JOBS. Default to eight on 32-bit targets and retain the linker default
elsewhere; callers can override the cap or leave it empty. Apply the flag
only to the ELF linker configuration.

(cherry picked from commit 1b927c6c3c7987e46ddfcb9172acdc822f409c50)

Assisted-by: Claude Code (Fable 5.1)
Assisted-by: Codex (GPT-6)
`CFI_NORETURN` emits `.cfi_undefined`/`.cfi_return_column` directives that
apply to whichever function the surrounding code is emitted in. The other
users in task.c were already `NOINLINE`, but the PGO+ThinLTO
macOS aarch64 build inlined `jl_start_fiber_set` into `ctx_switch` and
`jl_start_fiber_swap`.
That bound the whole FDE of those two functions to a CIE whose return
address register is undefined, so unwinding a suspended task from its
saved context stopped after one frame: the task profiler reported every
blocked task as a single `jl_start_fiber_swap` frame and the Profile test
failed on the optimized macOS aarch64 nightlies. Mark the function
`NOINLINE` and document the requirement next to the macro.

Assisted-by: Claude Code (Fable 5.1)
(cherry picked from commit e0e1225a55c4458b2dde162c3e82ec52885950ce)
Assisted-by: Codex (GPT-6)
@maleadt maleadt changed the title Windows x86-64 support for optimized builds contrib: add optimized Windows builds and fix Linux/macOS regressions Sep 16, 2026
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 performance Must go faster system:windows Affects only Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant