@@ -341,18 +341,6 @@ void buildAll(Bits bits, string branch)
341341 const dmdEnv = ` "DMD=` ~ cloneDir~ ` /dmd/generated/` ~ osDirName~ ` /release/` ~ bitsStr~ ` /dmd` ~ exe~ ` "` ;
342342 const isRelease = " ENABLE_RELEASE=1" ;
343343
344- // Enable lto for everything except FreeBSD - the generated dmd segfaults immediatly.
345- // OSX is disabled "temporarily" due to https://github.com/dlang/installer/actions/runs/12156929210/job/33901843249?pr=588#step:6:660
346- // wherein OSX with LTO timeTraceProfiler a TLS variable gets put into LTO layout which asserts out in ldc.
347- version (FreeBSD )
348- const ltoOption = " ENABLE_LTO=0" ;
349- else version (linux )
350- const ltoOption = " ENABLE_LTO=" ~ (is32 ? " 0" : " 1" );
351- else version (OSX )
352- const ltoOption = " ENABLE_LTO=0" ;
353- else
354- const ltoOption = " ENABLE_LTO=1" ;
355-
356344 const latest = " LATEST=" ~ branch;
357345 // PIC libraries on amd64 for PIE-by-default distributions, see Bugzilla 16794
358346 version (linux )
@@ -363,17 +351,36 @@ void buildAll(Bits bits, string branch)
363351 // common make arguments
364352 const makecmd = make~ jobs~ makeModel~ dmdEnv~ isRelease~ latest;
365353
366- info(" Building DMD " ~ bitsDisplay);
367- changeDir(cloneDir~ " /dmd" );
368- run(msvcVars~ makecmd~ ltoOption~ " HOST_DMD=" ~ hostDMD~ " dmd" );
354+ bool usePGO = true ;
355+ version (linux )
356+ {
357+ // the LDC Linux multilib package doesn't have any 32-bit compiler-rt libs
358+ if (is32)
359+ usePGO = false ;
360+ }
369361
370- info(" Building Druntime " ~ bitsDisplay);
371- changeDir(cloneDir~ " /dmd/druntime" );
372- run(msvcVars~ makecmd~ pic);
362+ if (usePGO)
363+ {
364+ string pgoDflags;
365+ version (OSX )
366+ {
367+ // As of September 2026 (with LDC v1.43), there are 15 warnings about profile
368+ // mismatches ('function control flow change detected (hash mismatch)').
369+ // No idea why on Mac only; don't treat them as errors.
370+ // (Enabling LTO for the instrumented compiler reduces them to 4 warnings.)
371+ pgoDflags = " HOST_DFLAGS=-wi" ;
372+ }
373373
374- info(" Building Phobos " ~ bitsDisplay);
375- changeDir(cloneDir~ " /phobos" );
376- run(msvcVars~ makecmd~ pic);
374+ info(" Building PGO+LTO'd dmd " ~ bitsDisplay~ " , incl. Druntime and Phobos" );
375+ changeDir(cloneDir~ " /dmd" );
376+ run(msvcVars~ makecmd~ pic~ " HOST_DMD=" ~ hostDMD~ pgoDflags~ " dmd-pgo" );
377+ }
378+ else
379+ {
380+ info(" Building LTO'd dmd " ~ bitsDisplay~ " , incl. Druntime and Phobos" );
381+ changeDir(cloneDir~ " /dmd" );
382+ run(msvcVars~ makecmd~ pic~ " HOST_DMD=" ~ hostDMD~ " ENABLE_LTO=1 all phobos" );
383+ }
377384
378385 // Build docs
379386 if (! skipDocs)
0 commit comments