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

x86 Mac OS Sonoma Compile Error with XCode 15 and #4454

Closed
KieranP opened this issue Sep 30, 2023 · 21 comments
Closed

x86 Mac OS Sonoma Compile Error with XCode 15 and #4454

KieranP opened this issue Sep 30, 2023 · 21 comments
Assignees
Labels
bug Something isn't working discuss during sync Should be discussed during an upcoming sync

Comments

@KieranP
Copy link

KieranP commented Sep 30, 2023

Upgraded from Ventura to Sonoma. Now getting the following error trying to compile code that used to work:

ponyc -d -b play
Building builtin -> /usr/local/Cellar/ponyc/0.56.2/packages/builtin
Building . -> /Users/kieran/Work/gol_implementations/pony
Building collections -> /usr/local/Cellar/ponyc/0.56.2/packages/collections
Building pony_test -> /usr/local/Cellar/ponyc/0.56.2/packages/pony_test
Building time -> /usr/local/Cellar/ponyc/0.56.2/packages/time
Building random -> /usr/local/Cellar/ponyc/0.56.2/packages/random
Building itertools -> /usr/local/Cellar/ponyc/0.56.2/packages/itertools
Building format -> /usr/local/Cellar/ponyc/0.56.2/packages/format
Generating
 Reachability
 Selector painting
 Data prototypes
 Data types
 Function prototypes
 Functions
 Descriptors
Writing ./play.o
Linking ./play
ld: Missing -platform_version option
Error:
unable to link: ld -execute -arch x86_64 -o ./play ./play.o -L"/usr/local/Cellar/ponyc/0.56.2/bin/" -L"/usr/local/Cellar/ponyc/0.56.2/bin/../lib/native" -L"/usr/local/Cellar/ponyc/0.56.2/bin/../packages" -L"/usr/local/lib"  -lponyrt -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lSystem
@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Sep 30, 2023
@SeanTAllen
Copy link
Member

@KieranP we don't have access to Sonoma machines. Can you see if you can figure out what this new required option is and tomorrow when I'm back, I can point you to where it would be added and you can open a PR?

@SeanTAllen SeanTAllen added help wanted Extra attention is needed bug Something isn't working good first issue Good for newcomers labels Sep 30, 2023
@SeanTAllen
Copy link
Member

The new option would go in link_exe in genexe.c

@KieranP
Copy link
Author

KieranP commented Sep 30, 2023

@SeanTAllen From the man ld docs:

     -platform_version platform min_version sdk_version
             This is set to indicate the platform, oldest supported version of that platform that output is to be used on, and the SDK that the output was built against.  platform is a numeric value as defined in <mach-o/loader.h>, or it may be one of the following
             strings:
             • macos
             • ios
             • tvos
             • watchos
             • bridgeos
             • visionos
             • xros
             • mac-catalyst
             • ios-simulator
             • tvos-simulator
             • watchos-simulator
             • visionos-simulator
             • xros-simulator
             • driverkit
             Specifying a newer min or SDK version enables the linker to assume features of that OS or SDK in the output file. The format of min_version and sdk_version is a version number such as 10.13 or 10.14

@KieranP
Copy link
Author

KieranP commented Sep 30, 2023

@SeanTAllen Looks like this might not just be a Sonoma issue, but introduced with the newest Xcode 15 release.

If I compile my app with pony up to the failed ld command, then re-run the ld command with platform_version, it works:

ld -execute -arch x86_64 -o ./play ./play.o -L"/usr/local/Cellar/ponyc/0.56.2/bin/" -L"/usr/local/Cellar/ponyc/0.56.2/bin/../lib/native" -L"/usr/local/Cellar/ponyc/0.56.2/bin/../packages" -L"/usr/local/lib"  -lponyrt -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lSystem -platform_version macos "13.0.0" "0.0.0"

@SeanTAllen
Copy link
Member

SeanTAllen commented Oct 1, 2023

Do you feel comfortable opening a PR for that?

Without testing on Apple Silicon, I'd want to keep it to x86 only for now as we have CI for it and we can wait for confirmation on Apple Silicon. If it doesn't cause issues with our CI which is an earlier Xcode, we can leave as general. Otherwise, we'll need to make it conditional on more than CPU.

@d-led
Copy link

d-led commented Oct 10, 2023

can confirm on Ventura too.

Re-running ld with -platform_version macos "13.0.0" "0.0.0" produces a binary, however, also brings out a warning:

ld: warning: no platform load command found in '/Users/....my.o', assuming: macOS`

interesting reference found: the "old" linker behaviour can be switched back to: -ld_classic

via blender

@SeanTAllen
Copy link
Member

SeanTAllen commented Oct 10, 2023

@d-led are you comfortable with opening a PR to try out the "classic"? option to see if works in CI (assuming it works for you locally). CI has an older xcode so hopefully we can work across xcode versions.

@SeanTAllen SeanTAllen removed the discuss during sync Should be discussed during an upcoming sync label Oct 10, 2023
@d-led
Copy link

d-led commented Oct 10, 2023

@SeanTAllen not sure I'll manage it in a timely fashion, so if anyone has a ready environment, don't wait for me. Will read genexe.c a bit while libs build.

Upd: make build suffers from the same problem while linking the tests: ld: Missing -platform_version option 😄

@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Oct 10, 2023
@d-led
Copy link

d-led commented Oct 11, 2023

I guess, the impact is not trivial. E.g. depending on which version of ld or other linker is used, -ld_classic might break the build for those linkers that don't support that flag

@SeanTAllen
Copy link
Member

@d-led if you can open a PR that fixes for you, CI will catch if it isn't backwards compatible. That will eliminate any guessing.

@SeanTAllen
Copy link
Member

@ergl @jemc can either of you address this?

@d-led
Copy link

d-led commented Oct 11, 2023

make build and libponyc.tests succeed at least locally with the two changes. It's a quick fix but hopefully in the right places

@SeanTAllen
Copy link
Member

It appears -ld_classic results in a link error on earlier xcode versions.

@SeanTAllen
Copy link
Member

-platform_version macos "13.0.0" "0.0.0"

at least builds and links. what is a reasonable sdk version for us to be putting in?

@SeanTAllen
Copy link
Member

@d-led I'm not getting any warnings in the CI logs for the change like this: #4466. Can you check with that change if you get the "ld: warning: no platform load command found in '/Users/....my.o', assuming: macOS`" warning?

@d-led
Copy link

d-led commented Oct 11, 2023

-platform_version macos "13.0.0" "0.0.0"
at least builds and links. what is a reasonable sdk version for us to be putting in?

unfortunately, I don't know. Perhaps, go with that proposal?

@SeanTAllen
Copy link
Member

@d-led @KieranP can either of you test the change on this branch/PR and verify if that installation works for you with XCode 15?

https://github.com/ponylang/ponyc/pull/4466/files

@SeanTAllen SeanTAllen removed the discuss during sync Should be discussed during an upcoming sync label Oct 17, 2023
@SeanTAllen SeanTAllen self-assigned this Oct 19, 2023
@SeanTAllen SeanTAllen removed help wanted Extra attention is needed good first issue Good for newcomers labels Oct 19, 2023
@jemc
Copy link
Member

jemc commented Oct 24, 2023

I'm having trouble reproducing this on the M1 Mac mini.

I am on Sonoma (version 14) with version 15 of XCode CLI tools installed:

 > pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version
version: 15.0.0.0.1.1694021235
> sw_vers
ProductName:		macOS
ProductVersion:		14.0
BuildVersion:		23A344

Building a Pony program succeeds, including the link step, which I can print by increasing verbosity:

> build/debug/ponyc examples/ring --verbose=3
Building builtin -> /Users/main/Documents/code/ponyc/packages/builtin
Building examples/ring -> /Users/main/Documents/code/ponyc/examples/ring
Building collections -> /Users/main/Documents/code/ponyc/packages/collections
Building pony_test -> /Users/main/Documents/code/ponyc/packages/pony_test
Building time -> /Users/main/Documents/code/ponyc/packages/time
Building random -> /Users/main/Documents/code/ponyc/packages/random
Program signature: 08518DCBB88DEC0B049B3D937E814C8897D0F2499E32A0774EDA5BC3AD25A456ACCF5BF0C6FF8559EF5AF12E8CD9B1994F7D90A0B9D43B62A48376196C403B2B

Group 0
Signature: 303AC86CA35D8FC6E5FAD0ED1721C946CA087E7029FC4D5034FC6D6BBA2523E5830FDDA3C3312FFD05C2CDAB76A046A020BACFFD4EFE602C364AB525D09CFF2B
Members:
  builtin
Dependencies:

Group 1
Signature: 0C9E6903C8D66340B6787EE6FEE28B4E0430B07147FAF02CB08868DC1FD43D5B1CF68F4446A17A041A7A77A2EA3787C173EFC6CFBF33468CA0544827AF697A4D
Members:
  collections
  random
  time
  pony_test
Dependencies:
  builtin

Group 2
Signature: CC273648BAE9BFA2344E19CC83A2F3FBF7104CBD1B8032F397CA18C8BF3C883A6C6977D23AE1F368AB63EE1078EBC78FFC4EBEA81B911EBEB50AABC1E460D1E3
Members:
  ring
Dependencies:
  builtin
  collections

Generating
 Reachability
 Selector painting
 Data prototypes
 Data types
 Function prototypes
 Functions
 Descriptors
Writing ./ring.o
Linking ./ring
ld -execute -arch arm64 -o ./ring ./ring.o -L"/Users/main/Documents/code/ponyc/build/debug/" -L"/Users/main/Documents/code/ponyc/build/debug/../../packages" -L"/usr/local/lib"  -lponyrt -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lSystem

@SeanTAllen
Copy link
Member

Joe and I have a fix for this. We are getting the PR into a mergeable state.

@d-led @KieranP if you can test the 'ldclassic' branch again, that would be great.

@SeanTAllen SeanTAllen changed the title Mac OS Sonoma Compile Error X86 Mac OS Sonoma Compile Error with XCode 15 and Oct 27, 2023
@SeanTAllen
Copy link
Member

I've updated the issue title to note that this is an X86 specific issue and that Apple Silicon is unaffected.

@SeanTAllen SeanTAllen removed the discuss during sync Should be discussed during an upcoming sync label Oct 27, 2023
@SeanTAllen SeanTAllen changed the title X86 Mac OS Sonoma Compile Error with XCode 15 and x86 Mac OS Sonoma Compile Error with XCode 15 and Oct 27, 2023
@KieranP
Copy link
Author

KieranP commented Oct 30, 2023

@SeanTAllen I can confirm that this is now resolved in 0.57.1

@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working discuss during sync Should be discussed during an upcoming sync
Projects
None yet
Development

No branches or pull requests

6 participants