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

x/mobile: gomobile is building for macOS 12.0, but I need 10.11 #52506

Closed
fortuna opened this issue Apr 22, 2022 · 15 comments
Closed

x/mobile: gomobile is building for macOS 12.0, but I need 10.11 #52506

fortuna opened this issue Apr 22, 2022 · 15 comments
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@fortuna
Copy link

fortuna commented Apr 22, 2022

At outline-go-tun2socks, I build a Framework that I import in an app (outline-client).

I recently upgraded Go to 1.18 and gomobile to "v0.0.0-20220407111146-e579adbbc4a2" to get support for xcframeworks. However, now gomobile outputs a Framework for macOS 12.0, but my app needs to support macOS 10.11.

How does gomobile specify the minimum macOS version, and is there a way to change it?

This is an example warning I now get when building my app:

Ld /Users/fortuna/Library/Developer/Xcode/DerivedData/Outline-fngalrotzadiujdbuypvqrfnnrrq/Build/Products/Debug/Outline.app/Contents/MacOS/Outline normal (in target 'Outline' from project 'Outline')
    cd /Users/fortuna/firehook/outline-client-2/platforms/osx
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target x86_64-apple-macos10.11 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -L/Users/fortuna/Library/Developer/Xcode/DerivedData/Outline-fngalrotzadiujdbuypvqrfnnrrq/Build/Products/Debug -F/Users/fortuna/Library/Developer/Xcode/DerivedData/Outline-fngalrotzadiujdbuypvqrfnnrrq/Build/Products/Debug -F/Users/fortuna/firehook/outline-client-2/platforms/osx/Outline/Plugins/cordova-plugin-outline -filelist /Users/fortuna/Library/Developer/Xcode/DerivedData/Outline-fngalrotzadiujdbuypvqrfnnrrq/Build/Intermediates.noindex/Outline.build/Debug/Outline.build/Objects-normal/x86_64/Outline.LinkFileList -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -rpath -Xlinker @executable_path/../Frameworks -Xlinker -object_path_lto -Xlinker /Users/fortuna/Library/Developer/Xcode/DerivedData/Outline-fngalrotzadiujdbuypvqrfnnrrq/Build/Intermediates.noindex/Outline.build/Debug/Outline.build/Objects-normal/x86_64/Outline_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -fobjc-arc -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/fortuna/Library/Developer/Xcode/DerivedData/Outline-fngalrotzadiujdbuypvqrfnnrrq/Build/Intermediates.noindex/Outline.build/Debug/Outline.build/Objects-normal/x86_64/Outline.swiftmodule -ObjC -framework ServiceManagement -framework CocoaLumberjackSwift /Users/fortuna/Library/Developer/Xcode/DerivedData/Outline-fngalrotzadiujdbuypvqrfnnrrq/Build/Products/Debug/libCordova.a -framework SystemConfiguration -framework CocoaLumberjack -framework WebKit -framework Cocoa -framework Sentry -framework NetworkExtension -framework Tun2socks -Xlinker -no_adhoc_codesign -Xlinker -dependency_info -Xlinker /Users/fortuna/Library/Developer/Xcode/DerivedData/Outline-fngalrotzadiujdbuypvqrfnnrrq/Build/Intermediates.noindex/Outline.build/Debug/Outline.build/Objects-normal/x86_64/Outline_dependency_info.dat -o /Users/fortuna/Library/Developer/Xcode/DerivedData/Outline-fngalrotzadiujdbuypvqrfnnrrq/Build/Products/Debug/Outline.app/Contents/MacOS/Outline

ld: warning: object file (/Users/fortuna/Library/Developer/Xcode/DerivedData/Outline-fngalrotzadiujdbuypvqrfnnrrq/Build/Products/Debug/Tun2socks.framework/Tun2socks(000007.o)) was built for newer macOS version (12.0) than being linked (10.11)
@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Apr 22, 2022
@gopherbot gopherbot added this to the Unreleased milestone Apr 22, 2022
@changkun
Copy link
Member

I don't know what we can do here.

Starting from Go 1.15, Go requires macOS 10.12, and Go 1.15 is already not supported today.

This basically means gomobile may not work for 10.11.

Maybe you could roll back to the historical gomobile version to see if it can be used to build for macOS 10.11? For instance, back to this?

@changkun changkun added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Apr 23, 2022
@fortuna
Copy link
Author

fortuna commented Apr 25, 2022

macOS 10.12 is actually good enough for me (I might get away with macOS 10.14, actually).

What's the latest Go version that supports 10.12?
I'm using Go 1.18, but gomobile is outputting code for macOS 12

How do I find that mapping of Go version to minimum supported macOS versions?
The page at https://github.com/golang/go/wiki/Darwin doesn't really give me that.

@changkun
Copy link
Member

@fortuna https://github.com/golang/go/wiki/MinimumRequirements

@fortuna
Copy link
Author

fortuna commented Apr 25, 2022

I found more information from the Go Release notes:

  • Go 1.16 is the last release that will run on macOS 10.12 Sierra.
  • Go 1.17 requires macOS 10.13 High Sierra or later; support for previous versions has been discontinued.
  • Go 1.18 now requires iOS 12 or later; support for previous versions has been discontinued.

I'll try to downgrade to 1.17 or 1.16 and see if that works for me.

@fortuna
Copy link
Author

fortuna commented Apr 25, 2022

@changkun the wiki you shared says "Go 1.17 and later only support macOS High Sierra 10.13 or newer". It doesn't say anything about Go 1.18, and I just realized that the Go 1.18 release notes referred to iOS, not macOS, v12.

Also: "We only have builders for 10.12, 10.14, 10.15, and 11.0 as of 2021-09-28."

Doesn't that mean that Go 1.18 should be outputting code for macOS 10.14 instead of macOS 12?

@fortuna
Copy link
Author

fortuna commented Apr 25, 2022

@changkun I built the framework with

$ go version
go version go1.17.9 darwin/amd64
$ uname -mrsv
Darwin 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64 x86_64

And still got the exact same error:

ld: warning: object file (/Users/fortuna/Library/Developer/Xcode/DerivedData/Outline-fngalrotzadiujdbuypvqrfnnrrq/Build/Products/Debug/Tun2socks.framework/Tun2socks(000042.o)) was built for newer macOS version (12.0) than being linked (10.14)

(Note that I've upgraded minimum version to macOS 10.14)

@fortuna
Copy link
Author

fortuna commented Apr 25, 2022

The same issue happens with Go 1.16.15. 😩

Is the problem the gomobile version, not the go version?

I can try to rollback gomobile, but that will be a bit of a pain because the old one doesn't support xcframeworks and I'll need to figure it out. I'd like to be confident that it would work.

@fortuna
Copy link
Author

fortuna commented Apr 25, 2022

I guess I need to specify -mmacosx-version-min somehow.

gomobile has the -iosversion option , which sets -miphoneos-version-min, but there's no equivalent for macOS in the current code.

Perhaps it can be implemented similarly to what's done for iOS: https://github.com/golang/mobile/blob/fea317f4e1ac8a39cd725d852b60936f25f2b23d/cmd/gomobile/env.go#L211

@gopherbot
Copy link

Change https://go.dev/cl/402294 mentions this issue: cmd/gomobile: add -macosversion

@changkun
Copy link
Member

@fortuna, I don't know whether CL 402294 works for you or not. It is also not clear if we should support older versions of macOS. Furthermore, I think gomobile is never officially supported for macOS (only test purpose) but only iOS.

Maybe cc @hyangah for an opinion.

@fortuna
Copy link
Author

fortuna commented Apr 26, 2022

I haven't tried CL 402294 yet. I did try setting MACOSX_DEPLOYMENT_TARGET=10.14 as an environment variable, and that partially changed the output. I now see a mix of 10.14 and 12.0 in the output:

$ otool -l build/apple/Tun2socks.xcframework/macos-arm64_x86_64/Tun2socks.framework/Tun2socks | grep minos
    minos 10.14
    minos 10.14
    minos 10.14
    minos 10.14
    minos 10.14
    minos 10.14
    minos 10.14
    minos 10.14
    minos 10.14
    minos 10.14
    minos 10.14
    minos 12.0
    minos 12.0
    minos 12.0
    minos 12.0
    minos 12.0
    minos 12.0
    minos 12.0
    minos 12.0
    minos 12.0
    minos 10.14
    minos 10.14
    minos 12.0
    minos 12.0
    minos 12.0
    minos 12.0
    minos 12.0
    minos 10.14
    minos 10.14
    minos 10.14
    minos 10.14
    minos 10.14
    minos 10.14
    minos 10.14
    minos 10.14
    minos 10.14
    minos 10.14
    minos 10.14
    minos 10.14
    minos 10.14
    minos 10.14
    minos 10.14
    minos 10.14
    minos 10.14
    minos 10.14

And only the object files with 12.0 trigger the warning:

  ld: warning: object file (/Users/fortuna/firehook/outline-client-2/platforms/osx/build/Tun2socks.framework/Tun2socks(000010.o)) was built for newer macOS version (12.0) than being linked (10.14)
  ld: warning: object file (/Users/fortuna/firehook/outline-client-2/platforms/osx/build/Tun2socks.framework/Tun2socks(000011.o)) was built for newer macOS version (12.0) than being linked (10.14)
  ld: warning: object file (/Users/fortuna/firehook/outline-client-2/platforms/osx/build/Tun2socks.framework/Tun2socks(000012.o)) was built for newer macOS version (12.0) than being linked (10.14)
  ld: warning: object file (/Users/fortuna/firehook/outline-client-2/platforms/osx/build/Tun2socks.framework/Tun2socks(000013.o)) was built for newer macOS version (12.0) than being linked (10.14)
  ld: warning: object file (/Users/fortuna/firehook/outline-client-2/platforms/osx/build/Tun2socks.framework/Tun2socks(000014.o)) was built for newer macOS version (12.0) than being linked (10.14)
  
  ld: warning: object file (/Users/fortuna/firehook/outline-client-2/platforms/osx/build/Tun2socks.framework/Tun2socks(000015.o)) was built for newer macOS version (12.0) than being linked (10.14)
  ld: warning: object file (/Users/fortuna/firehook/outline-client-2/platforms/osx/build/Tun2socks.framework/Tun2socks(000016.o)) was built for newer macOS version (12.0) than being linked (10.14)
  ld: warning: object file (/Users/fortuna/firehook/outline-client-2/platforms/osx/build/Tun2socks.framework/Tun2socks(000017.o)) was built for newer macOS version (12.0) than being linked (10.14)
  
  ld: warning: object file (/Users/fortuna/firehook/outline-client-2/platforms/osx/build/Tun2socks.framework/Tun2socks(000018.o)) was built for newer macOS version (12.0) than being linked (10.14)
  ld: warning: object file (/Users/fortuna/firehook/outline-client-2/platforms/osx/build/Tun2socks.framework/Tun2socks(000021.o)) was built for newer macOS version (12.0) than being linked (10.14)
  ld: warning: object file (/Users/fortuna/firehook/outline-client-2/platforms/osx/build/Tun2socks.framework/Tun2socks(000022.o)) was built for newer macOS version (12.0) than being linked (10.14)
  ld: warning: object file (/Users/fortuna/firehook/outline-client-2/platforms/osx/build/Tun2socks.framework/Tun2socks(000023.o)) was built for newer macOS version (12.0) than being linked (10.14)
  
  ld: warning: object file (/Users/fortuna/firehook/outline-client-2/platforms/osx/build/Tun2socks.framework/Tun2socks(000024.o)) was built for newer macOS version (12.0) than being linked (10.14)
  ld: warning: object file (/Users/fortuna/firehook/outline-client-2/platforms/osx/build/Tun2socks.framework/Tun2socks(000025.o)) was built for newer macOS version (12.0) than being linked (10.14)

That's progress, but I need all the object files to be 10.14.

I don't know why they didn't all change.

In any case, it would be great to see the CL merged. macos is already a gomobile target. I don't see the harm of being able to configure it.

Alternatively, we could add an "extra cflags" flag to gomobile, that way I could just pass the -mmacosx-version-min flag as extra.

@fortuna
Copy link
Author

fortuna commented Apr 26, 2022

Wait, IT WORKED!

The problem was the build cache. After I did a go clean -cache, MACOSX_DEPLOYMENT_TARGET=10.14 worked. Everything is 10.14 now.

@changkun
Copy link
Member

@fortuna Is it worked after a cache clean or worked because of the CL?

@fortuna
Copy link
Author

fortuna commented Apr 26, 2022

@changkun It worked because of the cache clean. I did not use the CL.

@changkun
Copy link
Member

Thanks, I think this is not an issue anymore. Close.

@golang golang locked and limited conversation to collaborators Apr 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants