blueboxd / chromium-legacy

Latest Chromium (≒Chrome Canary/Stable) for Mac OS X 10.7+
BSD 3-Clause "New" or "Revised" License
306 stars 17 forks source link

question about compiling for 10.7 #234

Open GitHub2FAblows opened 3 months ago

GitHub2FAblows commented 3 months ago

hi,

just curious, did you have to do anything special to compile for 10.7 target?

when i first used lld, i got this issue:

GagansMacPro:updater Gagan$ /opt/local/bin/ccache /opt/local/bin/clang++ -isysroot /Users/Gagan/.mozbuild/MacOSX14.4.sdk -objc -mmacosx-version-min=10.7 -stdlib=libc++ -o ../../../../dist/bin/org.mozilla.updater -fstack-protector-strong -fno-sized-deallocation -fno-aligned-new -fno-exceptions -fPIC -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -pthread -gdwarf-4 -fno-omit-frame-pointer -funwind-tables -Wl,@/Users/Gagan/Downloads/mozilla-unified/obj-x86_64-apple-darwin18.7.0/toolkit/mozapps/update/updater/org_mozilla_updater.list    -fuse-ld=lld -fstack-protector-strong -Wl,-rpath,@executable_path/../Frameworks/UpdateSettings.framework -sectcreate __TEXT __info_plist /Users/Gagan/Downloads/mozilla-unified/obj-x86_64-apple-darwin18.7.0/dist/bin/Info.plist -sectcreate __TEXT __launchd_plist /Users/Gagan/Downloads/mozilla-unified/toolkit/mozapps/update/updater/Launchd.plist  ../../../../build/pure_virtual/libpure_virtual.a -Wl,-rpath,@executable_path ../../../../dist/bin/UpdateSettings -framework Security -framework Cocoa -framework SystemConfiguration
ld64.lld: error: undefined symbol: OBJC_CLASS_$_NSObject
referenced by /Users/Gagan/Downloads/mozilla-unified/toolkit/mozapps/update/updater/launchchild_osx.mm
             launchchild_osx.o:(symbol OBJC_CLASS_$_ElevatedUpdateServer+0x8)
referenced by /Users/Gagan/Downloads/mozilla-unified/toolkit/mozapps/update/updater/progressui_osx.mm
             progressui_osx.o:(symbol OBJC_CLASS_$_UpdaterUI+0x8)

ld64.lld: error: undefined symbol: OBJC_METACLASS_$_NSObject
referenced by /Users/Gagan/Downloads/mozilla-unified/toolkit/mozapps/update/updater/launchchild_osx.mm
             launchchild_osx.o:(symbol OBJC_METACLASS_$_ElevatedUpdateServer+0x8)
referenced by /Users/Gagan/Downloads/mozilla-unified/toolkit/mozapps/update/updater/launchchild_osx.mm
             launchchild_osx.o:(symbol OBJC_METACLASS_$_ElevatedUpdateServer+0x0)
referenced by /Users/Gagan/Downloads/mozilla-unified/toolkit/mozapps/update/updater/progressui_osx.mm
             progressui_osx.o:(symbol OBJC_METACLASS_$_UpdaterUI+0x8)
referenced 1 more times

but fixed it using ld64.

now when i build for 10.7, there are no linking errors but there is problems linking coretext (which can be fixed using this link), but also with NSLayout constraint (https://stackoverflow.com/questions/13110529/i-am-getting-this-error-on-using-matplotlib):

XPCOMGlueLoad error for file /Users/vm/Desktop/Firefox.app/Contents/MacOS/XUL:
dlopen(/Users/vm/Desktop/Firefox.app/Contents/MacOS/XUL, 265): Symbol not found: _OBJC_CLASS_$_NSLayoutConstraint
 Referenced from: /Users/vm/Desktop/Firefox.app/Contents/MacOS/XUL
 Expected in: /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
in /Users/vm/Desktop/Firefox.app/Contents/MacOS/XUL

credit to @krackers for helping me fix these as much as he possibly could (if it's the same guy haha)

Jazzzny commented 2 months ago

I may be wrong on this, but after some looking around, I believe this is because of an SDK bug present in Big Sur and newer

Things to note:

$ld$hide$os10.7$_OBJC_CLASS_$_NSLayoutConstraint was defined in Foundation.tbd in the 10.10-10.15 SDKs, which I believe prevented ld from trying to link the symbol to Foundation when 10.7 is set as the deployment target, this was seemingly moved to CoreAutoLayout.tbd in the Big Sur SDK (CoreAutoLayout.framework was introduced in Big Sur so this wouldn't work by design), but the NSLayoutConstraint definition is still present in Foundation $ld$add$os10.7$_OBJC_CLASS_$_NSLayoutConstraint is defined in AppKit.tbd in the 10.10+ SDKs, seemingly to provide the legacy AppKit symbol.

Therefore, I believe readding $ld$hide$os10.7$_OBJC_CLASS_$_NSLayoutConstraint to Foundation.tbd in the macOS 14 SDK should prevent ld from linking _OBJC_CLASS_$_NSLayoutConstraint to Foundation (where it is still defined seemingly without the 10.7 safeguard intact) and instead make it link to AppKit, where it is present.

Wowfunhappy commented 2 months ago

^ The above theory is promising IMO, because we know Bluebox makes SDK edits to compile Chromium Legacy, and if he made new ones since the wiki was written he probably hasn't documented them.