Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question about compiling for 10.7 #234

Open
GitHub2FAblows opened this issue Jul 20, 2024 · 2 comments
Open

question about compiling for 10.7 #234

GitHub2FAblows opened this issue Jul 20, 2024 · 2 comments

Comments

@GitHub2FAblows
Copy link

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
Copy link

Jazzzny commented Aug 25, 2024

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:

  • 10.7 does not have _OBJC_CLASS_$_NSLayoutConstraint present in Foundation.framework - this can be verified by running nm -g on a copy of the 10.7 Foundation framework
  • However, 10.7 does have _OBJC_CLASS_$_NSLayoutConstraint present in AppKit.framework
  • 10.8 and newer have it in both

$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
Copy link

^ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants