[llvm] [MachO] Preserve weak linkage for aliases (PR #198148)

via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 18 20:41:53 PDT 2026


================
@@ -443,7 +443,10 @@ void MachObjectWriter::writeNlist(MachSymbolData &MSD, const MCAssembler &Asm) {
   // The Mach-O streamer uses the lowest 16-bits of the flags for the 'desc'
   // value.
   bool EncodeAsAltEntry = IsAlias && OrigSymbol.isAltEntry();
-  W.write<uint16_t>(Symbol->getEncodedFlags(EncodeAsAltEntry));
+  uint16_t Flags = Symbol->getEncodedFlags(EncodeAsAltEntry);
+  if (IsAlias)
+    Flags |= OrigSymbol.getEncodedFlags(EncodeAsAltEntry);
----------------
syhhyl wrote:

I performed the requested end-to-end testing with rustc at eff8269f797067c30555e77f160ec84c0ed15cd9 on Apple arm64.

I applied this LLVM change to the LLVM fork used by rustc, temporarily disabled rustc's Apple-specific restriction on static EII defaults for testing, and ran the following stage 1 tests:

- tests/ui/eii/static/default.rs
- tests/ui/eii/static/default_cross_crate.rs
- tests/ui/eii/static/default_cross_crate_explicit.rs

All three tests passed. In particular, the cross-crate test successfully compiled, linked, and ran, covering the original failure mode where the weak alias was not externally linkable.

https://github.com/llvm/llvm-project/pull/198148


More information about the llvm-commits mailing list