Skip to content

Commit

Permalink
Update DEFAULT_MACOS_CPU to match host
Browse files Browse the repository at this point in the history
With Apple Silicon machines host tools that use the apple_binary, or
apple fragment to fetch the CPU would be built for the wrong
architecture, even though the C++ logic would correctly identify the
host CPU. This changes this hardcoded value to correctly determine Apple
Silicon as arm64, and otherwise fallback to x86_64.

Fixes #12671

Closes #13440.

PiperOrigin-RevId: 373421791
  • Loading branch information
keith authored and copybara-github committed May 12, 2021
1 parent c99992c commit aaae8ce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.google.devtools.build.lib.skyframe.serialization.SerializationContext;
import com.google.devtools.build.lib.skyframe.serialization.SerializationException;
import com.google.devtools.build.lib.starlarkbuildapi.apple.AppleBitcodeModeApi;
import com.google.devtools.build.lib.util.CPU;
import com.google.devtools.common.options.Converters.CommaSeparatedOptionListConverter;
import com.google.devtools.common.options.EnumConverter;
import com.google.devtools.common.options.Option;
Expand Down Expand Up @@ -186,7 +187,8 @@ public class AppleCommandLineOptions extends FragmentOptions {
public static final String DEFAULT_TVOS_CPU = "x86_64";

/** The default macOS CPU value. */
public static final String DEFAULT_MACOS_CPU = "x86_64";
public static final String DEFAULT_MACOS_CPU =
CPU.getCurrent() == CPU.AARCH64 ? "arm64" : "x86_64";

/** The default Catalyst CPU value. */
public static final String DEFAULT_CATALYST_CPU = "x86_64";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/skyframe/serialization",
"//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec",
"//src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple",
"//src/main/java/com/google/devtools/build/lib/util",
"//src/main/java/com/google/devtools/common/options",
"//src/main/java/net/starlark/java/eval",
"//src/main/java/net/starlark/java/syntax",
Expand Down

0 comments on commit aaae8ce

Please sign in to comment.