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

Kernel build produces scary warnings when using Xcode 15 and targeting macOS 13.0 #457

Open
eschaton opened this issue Sep 22, 2023 · 5 comments

Comments

@eschaton
Copy link

I tried to build CCL trunk’s kernel for x86-64 Darwin using Xcode 15, and it produces a bunch of errors if I change OS_VERSION in the kernel Makefile to 13.0:

ld: warning: prefered load addresses (-seg1addr) are disabled with chained fixups
ld: warning: -no_pie is deprecated when targeting new OS versions
ld: warning: prefered load addresses (-seg1addr) are disabled with chained fixups
ld: warning: non-standard -pagezero_size is deprecated when targeting macOS 13.0 or later
ld: warning: alignment (1) of atom '_subprims_end' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom '_subprims_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom '_import_ptrs_base' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'import_ptrs_start' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom '_spentry_end' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom '_spentry_start' is too small and may result in unaligned pointers

My understanding of the new linker is that it produces many more diagnostics so, while the resulting kernel binary appears to run fine for me (under Rosetta no less) these are probably worth investigating.

@xrme
Copy link
Member

xrme commented Sep 22, 2023

I suppose we could use -ld64 to avoid the scary warnings in the short term, but I certainly agree that we ought to track down the cause of these warnings and make corrections.

@ghost
Copy link

ghost commented Sep 22, 2023

I can open a separate thread, if you want, but is building the kernel (an older version, on an ancient macOS version) with Xcode documented somewhere?

I've been away from using CCL and Xcode while, and I'm stuck. Thanks!

@xrme
Copy link
Member

xrme commented Sep 23, 2023

@melodious-thunk, the lisp kernel doesn't build with the Xcode IDE; it uses the usual command-line tools that come with Xcode. If you are on an old macOS version, you'll need to track down the Xcode tools that run on it. https://xcodereleases.com has links.

You might also need to use an older version of CCL. Look at https://trac.clozure.com/ccl/wiki/TitleIndex for links of the form https://trac.clozure.com/ccl/wiki/ReleaseNotes/1.4 — I think we made releases that ran on systems as old Mac OS X 10.4. There might be even older stuff, but I don't know much about it.

For future discussion, I suggest making a new discussion at https://github.com/Clozure/ccl/discussions or posting to the mailing list.

@xrme
Copy link
Member

xrme commented Sep 30, 2023

Probably need to sprinkle a few .p2align 3 lines in there for the alignment warnings.

I'm not sure what to do about the -no_pie warning. CCL wants control of its address space, so it's not just a matter of leaving it out.

@xrme
Copy link
Member

xrme commented May 24, 2024

ld: warning: prefered load addresses (-seg1addr) are disabled with chained fixups
ld: warning: -no_pie is deprecated when targeting new OS versions
ld: warning: prefered load addresses (-seg1addr) are disabled with chained fixups
ld: warning: non-standard -pagezero_size is deprecated when targeting macOS 13.0 or later

We can use the -no_fixup_chains linker option to silence the chained fixup warnings. That means our link command would look like this:

cc -Wl,-no_fixup_chains,-no_pie,-pagezero_size,0x10000,-seg1addr,0x10000 ...

But I’m not sure what to do about the warnings about -no_pie and -pagezero_size. CCL wants to have some stuff laid out in fixed locations in (relatively) low memory. If Apple gets rid of those options, I think we’ll be in some trouble.

As long as we pass, say, -mmacos-version-min=10.15, then we don’t get the warnings, but future problems often arrive before you know it.

I also just ran across https://developer.apple.com/forums/thread/655950, which says "Modifying pagezero_size isn't a supportable option in the arm64 environment. arm64 code must be in an ASLR binary, which using a custom pagezero_size is incompatible with. An ASLR binary encodes signed pointers using a large random size along with the expected page zero size, and this combination is going to extend beyond the range of values covered in the lower 32-bits.”

If that’s the case, then that may be an exciting problem for an ARM64 port (well, an Apple silicon port in particular, I suppose).

On an Apple silicon Mac, it works to compile with cc -Wl,-pagezero_size,0x4000 -g foo.c, but that produces a binary that won't run: "error: Malformed Mach-o file" is what the debugger prints out.

On an Intel Mac, that same cc -Wl,-pagezero_size,0x4000 -g foo.c produces a binary that runs.

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

2 participants