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

Build xcode-locator as a universal binary #14168

Conversation

EdSchouten
Copy link
Contributor

One of Buildbarn's users is attempting to build it on a Mac M1 system
that does not have Rosetta installed:

buildbarn/bb-remote-execution#89

This currently fails with the following error message:

ERROR: <storage>/external/com_google_protobuf/BUILD:130:11: Compiling src/google/protobuf/extension_set.cc failed: I/O exception during sandboxed execution: com.google.devtools.build.lib.shell.ExecFailedException: java.io.IOException: Cannot run program "<tmp>/install/71ed47cad951a20fff87381f54639763/xcode-locator": error=86, Bad CPU type in executable

Let's address this by shipping a copy of xcode-locator that is built
both for ARM64 and x86-64.

@brentleyjones
Copy link
Contributor

Related, though different: #13452

@keith
Copy link
Member

keith commented Oct 26, 2021

yea mine doesn't touch this tool, I was just allowing this one to run with rosetta for now

@keith
Copy link
Member

keith commented Oct 26, 2021

This CI issue looks unrelated, I filed bazelbuild/continuous-integration#1269

@keith
Copy link
Member

keith commented Oct 26, 2021

so this compile isn't hermetic because of an issue with linking on the M1, you have to use the same approach I did here to resolve that for now https://github.com/bazelbuild/bazel/pull/13452/files#diff-a974c428038be37758ceec95a81b78f4fd5cb7051e8d6c9e20c13a8337b0c8ddR112 by passing -Wl,-no_adhoc_codesign and then explicitly signing the binary. I think this will be fixed in a future version of the linker, but who knows when it will come

@keith
Copy link
Member

keith commented Oct 26, 2021

That is why the test is failing here

@EdSchouten
Copy link
Contributor Author

Interesting. I just added -Wl,-no_adhoc_codesign to DARWIN_XCODE_LOCATOR_COMPILE_COMMAND and the resulting executable is still not deterministic.

One of Buildbarn's users is attempting to build it on a Mac M1 system
that does not have Rosetta installed:

buildbarn/bb-remote-execution#89

This currently fails with the following error message:

    ERROR: <storage>/external/com_google_protobuf/BUILD:130:11: Compiling src/google/protobuf/extension_set.cc failed: I/O exception during sandboxed execution: com.google.devtools.build.lib.shell.ExecFailedException: java.io.IOException: Cannot run program "<tmp>/install/71ed47cad951a20fff87381f54639763/xcode-locator": error=86, Bad CPU type in executable

Let's address this by shipping a copy of xcode-locator that is built
both for ARM64 and x86-64.
@EdSchouten EdSchouten force-pushed the eschouten/20211026-xcode-locator branch from 980ab9e to 447f012 Compare October 28, 2021 08:04
@EdSchouten
Copy link
Contributor Author

Ah! You also need -Wl,-no_uuid. Updated the PR to do separate codesigning. Thanks for your input, @keith !

@keith
Copy link
Member

keith commented Oct 28, 2021

You shouldn't need that as well since the default is to produce a UUID based on the contents 🤔

@keith
Copy link
Member

keith commented Oct 28, 2021

Ok I debugged that and verified it's a bug in ld64 that leads to non hermetic links. I filed FB9727658 with apple and also submitted swiftlang/llvm-project#3483 as a cherry pick to attempt to get the fix into Xcode sooner. But passing -no_uuid should be harmless for this use case for now anyways

@keith
Copy link
Member

keith commented Oct 28, 2021

So the reason I hadn't reproduced this is because there was a difference in this behavior based on whether the -Wl,-flag came before or after the input source file name https://reviews.llvm.org/D112767

I think this current solution is the right move just to be safe

keith added a commit to keith/bazel that referenced this pull request Oct 28, 2021
The content based uuid embedded by ld64 contains the basename of the
file being built. In the case of multiarch builds this filename is
randomly generated. This doesn't hit in all cases based on the order of
the arguments to clang, but since this shouldn't have a downside for
this use case, it's safer to exclude this for the future.

More conversation bazelbuild#14168

Filed with apple as FB9727658
keith added a commit to keith/bazel that referenced this pull request Oct 28, 2021
The content based uuid embedded by ld64 contains the basename of the
file being built. In the case of multiarch builds this filename is
randomly generated. This doesn't hit in all cases based on the order of
the arguments to clang, but since this shouldn't have a downside for
this use case, it's safer to exclude this for the future.

More conversation bazelbuild#14168

Filed with apple as FB9727658

(cherry picked from commit d2aab87)
@keith
Copy link
Member

keith commented Oct 28, 2021

@oquenchil can you review?

@oquenchil oquenchil self-requested a review November 2, 2021 14:31
@oquenchil oquenchil self-assigned this Nov 2, 2021
bazel-io pushed a commit that referenced this pull request Nov 5, 2021
The content based uuid embedded by ld64 contains the basename of the
file being built. In the case of multiarch builds this filename is
randomly generated. This doesn't hit in all cases based on the order of
the arguments to clang, but since this shouldn't have a downside for
this use case, it's safer to exclude this for the future.

More conversation #14168

Filed with apple as FB9727658

Closes #14190.

PiperOrigin-RevId: 407784532
Wyverald pushed a commit that referenced this pull request Nov 5, 2021
The content based uuid embedded by ld64 contains the basename of the
file being built. In the case of multiarch builds this filename is
randomly generated. This doesn't hit in all cases based on the order of
the arguments to clang, but since this shouldn't have a downside for
this use case, it's safer to exclude this for the future.

More conversation #14168

Filed with apple as FB9727658

(cherry picked from commit d2aab87)
@EdSchouten
Copy link
Contributor Author

EdSchouten commented Nov 26, 2021

Ping! Would be nice if this ended up in Bazel 5.

@EdSchouten EdSchouten mentioned this pull request Nov 26, 2021
9 tasks
@meteorcloudy
Copy link
Member

meteorcloudy commented Nov 29, 2021

An internal test is failing with:

ERROR: No signing identity found for 'Apple Development: Google Development'

Can you help fixing this? Maybe related to --force --sign, is that necessary?

Update: the change submitted successfully, maybe it's a false alarm.

@bazel-io bazel-io closed this in 76b3c24 Nov 29, 2021
@meteorcloudy
Copy link
Member

@EdSchouten Can you make a PR to release-5.0.0rc2?

@meteorcloudy meteorcloudy reopened this Nov 29, 2021
brentleyjones pushed a commit to brentleyjones/bazel that referenced this pull request Nov 30, 2021
One of Buildbarn's users is attempting to build it on a Mac M1 system
that does not have Rosetta installed:

buildbarn/bb-remote-execution#89

This currently fails with the following error message:

    ERROR: <storage>/external/com_google_protobuf/BUILD:130:11: Compiling src/google/protobuf/extension_set.cc failed: I/O exception during sandboxed execution: com.google.devtools.build.lib.shell.ExecFailedException: java.io.IOException: Cannot run program "<tmp>/install/71ed47cad951a20fff87381f54639763/xcode-locator": error=86, Bad CPU type in executable

Let's address this by shipping a copy of xcode-locator that is built
both for ARM64 and x86-64.

Closes bazelbuild#14168.

PiperOrigin-RevId: 412864310
(cherry picked from commit 76b3c24)
meteorcloudy pushed a commit that referenced this pull request Dec 1, 2021
One of Buildbarn's users is attempting to build it on a Mac M1 system
that does not have Rosetta installed:

buildbarn/bb-remote-execution#89

This currently fails with the following error message:

    ERROR: <storage>/external/com_google_protobuf/BUILD:130:11: Compiling src/google/protobuf/extension_set.cc failed: I/O exception during sandboxed execution: com.google.devtools.build.lib.shell.ExecFailedException: java.io.IOException: Cannot run program "<tmp>/install/71ed47cad951a20fff87381f54639763/xcode-locator": error=86, Bad CPU type in executable

Let's address this by shipping a copy of xcode-locator that is built
both for ARM64 and x86-64.

Closes #14168.

PiperOrigin-RevId: 412864310
(cherry picked from commit 76b3c24)

Co-authored-by: Ed Schouten <eschouten@apple.com>
@meteorcloudy
Copy link
Member

Merged into release-5.0.0rc2

Bencodes pushed a commit to Bencodes/bazel that referenced this pull request Jan 10, 2022
One of Buildbarn's users is attempting to build it on a Mac M1 system
that does not have Rosetta installed:

buildbarn/bb-remote-execution#89

This currently fails with the following error message:

    ERROR: <storage>/external/com_google_protobuf/BUILD:130:11: Compiling src/google/protobuf/extension_set.cc failed: I/O exception during sandboxed execution: com.google.devtools.build.lib.shell.ExecFailedException: java.io.IOException: Cannot run program "<tmp>/install/71ed47cad951a20fff87381f54639763/xcode-locator": error=86, Bad CPU type in executable

Let's address this by shipping a copy of xcode-locator that is built
both for ARM64 and x86-64.

Closes bazelbuild#14168.

PiperOrigin-RevId: 412864310
@coeuvre
Copy link
Member

coeuvre commented Jan 24, 2023

Just observed that the resulting executable is not deterministic with either Xcode 13.4 or 14.0.

@keith
Copy link
Member

keith commented Jan 24, 2023 via email

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

Successfully merging this pull request may close these issues.

6 participants