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

Include CPU in darwin platform string #7062

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ public class AutoCpuConverter implements Converter<String> {
@Override
public String convert(String input) throws OptionsParsingException {
if (input.isEmpty()) {
// TODO(philwo) - replace these deprecated names with more logical ones (e.g. k8 becomes
// linux-x86_64, darwin includes the CPU architecture, ...).
// TODO(philwo) - replace these deprecated names with more logical ones (e.g. k8 becomes linux-x86_64, ...).
switch (OS.getCurrent()) {
case DARWIN:
return "darwin";
return "darwin_x86_64";
case FREEBSD:
return "freebsd";
case WINDOWS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ toolchain {

host_system_name: "local"
target_system_name: "local"
target_cpu: "darwin"
target_cpu: "darwin_x86_64"
target_libc: "macosx"
compiler: "compiler"
linking_mode_flags { mode: DYNAMIC }
Expand Down Expand Up @@ -407,7 +407,7 @@ toolchain {
toolchain_identifier: "darwin-no-dyn-linker"
host_system_name: "local"
target_system_name: "local"
target_cpu: "darwin"
target_cpu: "darwin_x86_64"
target_libc: "macosx"
compiler: "compiler_no_dyn_linker"
# No linking_mode_flags here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void setup(MockToolsConfig config) throws IOException {
" 'local': ':cc-compiler-local',",
" 'k8': ':cc-compiler-k8',",
" 'piii': ':cc-compiler-piii-gcc-4.4.0',",
" 'darwin': ':cc-compiler-darwin',",
" 'darwin_x86_64': ':cc-compiler-darwin_x86_64',",
" 'ios_x86_64': ':cc-compiler-ios_x86_64',",
" 'armeabi-v7a': ':cc-compiler-armeabi-v7a',",
" 'x64_windows': ':cc-compiler-x64_windows',",
Expand All @@ -95,8 +95,8 @@ public void setup(MockToolsConfig config) throws IOException {
" 'k8|compiler': ':cc-compiler-k8',",
" 'k8|compiler_no_dyn_linker': ':cc-no-dyn-linker-k8',",
" 'piii|compiler': ':cc-compiler-piii-gcc-4.4.0',",
" 'darwin|compiler': ':cc-compiler-darwin',",
" 'darwin|compiler_no_dyn_linker': ':cc-no-dyn-linker-darwin',",
" 'darwin_x86_64|compiler': ':cc-compiler-darwin_x86_64',",
" 'darwin_x86_64|compiler_no_dyn_linker': ':cc-no-dyn-linker-darwin_x86_64',",
" 'ios_x86_64|compiler': ':cc-compiler-ios_x86_64',",
" 'armeabi-v7a|compiler': ':cc-compiler-armeabi-v7a',",
" 'x64_windows|windows_msys64': ':cc-compiler-x64_windows',",
Expand Down Expand Up @@ -200,43 +200,43 @@ public void setup(MockToolsConfig config) throws IOException {
" toolchain = ':cc-compiler-piii-gcc-4.4.0',",
" toolchain_type = ':toolchain_type',",
")",
"cc_toolchain(name = 'cc-compiler-darwin', all_files = ':empty', ",
"cc_toolchain(name = 'cc-compiler-darwin_x86_64', all_files = ':empty', ",
" compiler_files = ':empty',",
" cpu = 'darwin',",
" cpu = 'darwin_x86_64',",
" compiler = 'compiler',",
" dwp_files = ':empty',",
" dynamic_runtime_lib = ':empty', ",
" ar_files = ':empty', as_files = ':empty', linker_files = ':empty',",
" module_map = 'crosstool.cppmap', supports_header_parsing = 1,",
" objcopy_files = ':empty', static_runtime_lib = ':empty', strip_files = ':empty',",
")",
"toolchain(name = 'cc-toolchain-darwin',",
"toolchain(name = 'cc-toolchain-darwin_x86_64',",
// Needs to be compatible with all execution environments for tests to work properly.
" exec_compatible_with = [],",
" target_compatible_with = [",
" '@bazel_tools//platforms:x86_64',",
" '@bazel_tools//platforms:osx',",
" ],",
" toolchain = ':cc-compiler-darwin',",
" toolchain = ':cc-compiler-darwin_x86_64',",
" toolchain_type = ':toolchain_type',",
")",
"cc_toolchain(name = 'cc-no-dyn-linker-darwin', all_files = ':empty', ",
"cc_toolchain(name = 'cc-no-dyn-linker-darwin_x86_64', all_files = ':empty', ",
" compiler_files = ':empty',",
" cpu = 'darwin',",
" cpu = 'darwin_x86_64',",
" compiler = 'compiler_no_dyn_linker',",
" dwp_files = ':empty', dynamic_runtime_lib = ':empty', ",
" ar_files = ':empty', as_files = ':empty', linker_files = ':empty',",
" module_map = 'crosstool.cppmap', supports_header_parsing = 1,",
" objcopy_files = ':empty', static_runtime_lib = ':empty', strip_files = ':empty',",
")",
"toolchain(name = 'cc-toolchain-no-dyn-linker-darwin',",
"toolchain(name = 'cc-toolchain-no-dyn-linker-darwin_x86_64',",
// Needs to be compatible with all execution environments for tests to work properly.
" exec_compatible_with = [],",
" target_compatible_with = [",
" '@bazel_tools//platforms:x86_64',",
" '@bazel_tools//platforms:osx',",
" ],",
" toolchain = ':cc-no-dyn-linker-darwin',",
" toolchain = ':cc-no-dyn-linker-darwin_x86_64',",
" toolchain_type = ':toolchain_type',",
")",
"cc_toolchain(name = 'cc-compiler-ios_x86_64', all_files = ':empty', ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static String defaultCpu() {
return "unknown";
}
}
return OS.getCurrent() == OS.DARWIN ? "darwin" : "k8";
return OS.getCurrent() == OS.DARWIN ? "darwin_x86_64" : "k8";
}

public static CrosstoolConfig.CrosstoolRelease simpleCompleteToolchainProto() {
Expand Down
14 changes: 7 additions & 7 deletions tools/cpp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ cc_toolchain_suite(
name = "default-toolchain",
toolchains = {
"armeabi-v7a|compiler": ":cc-compiler-armeabi-v7a",
"darwin|compiler": ":cc-compiler-darwin",
"darwin_x86_64|compiler": ":cc-compiler-darwin",
"freebsd|compiler": ":cc-compiler-freebsd",
"local|compiler": ":cc-compiler-local",
"x64_windows|compiler": ":cc-compiler-x64_windows",
Expand All @@ -102,7 +102,7 @@ cc_toolchain_suite(
"s390x": ":cc-compiler-local",
"ppc": ":cc-compiler-local",
"ppc64": ":cc-compiler-local",
"darwin": ":cc-compiler-darwin",
"darwin_x86_64": ":cc-compiler-darwin",
"freebsd": ":cc-compiler-freebsd",
"armeabi-v7a": ":cc-compiler-armeabi-v7a",
"x64_windows": ":cc-compiler-x64_windows",
Expand Down Expand Up @@ -227,24 +227,24 @@ toolchain(
)

cc_toolchain(
name = "cc-compiler-darwin",
name = "cc-compiler-darwin_x86_64",
all_files = ":osx_wrapper",
ar_files = ":empty",
as_files = ":empty",
compiler_files = ":osx_wrapper",
cpu = "darwin",
cpu = "darwin_x86_64",
dwp_files = ":empty",
dynamic_runtime_libs = [":empty"],
linker_files = ":osx_wrapper",
objcopy_files = ":empty",
static_runtime_libs = [":empty"],
strip_files = ":empty",
supports_param_files = 0,
toolchain_identifier = "local_darwin",
toolchain_identifier = "local_darwin_x86_64",
)

toolchain(
name = "cc-toolchain-darwin",
name = "cc-toolchain-darwin_x86_64",
exec_compatible_with = [
"@bazel_tools//platforms:x86_64",
"@bazel_tools//platforms:osx",
Expand All @@ -253,7 +253,7 @@ toolchain(
"@bazel_tools//platforms:x86_64",
"@bazel_tools//platforms:osx",
],
toolchain = ":cc-compiler-darwin",
toolchain = ":cc-compiler-darwin_x86_64",
toolchain_type = ":toolchain_type",
)

Expand Down
4 changes: 2 additions & 2 deletions tools/cpp/CROSSTOOL
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ toolchain {
host_system_name: "local"
needsPic: true
target_libc: "macosx"
target_cpu: "darwin"
target_cpu: "darwin_x86_64"
target_system_name: "local"
toolchain_identifier: "local_darwin"
toolchain_identifier: "local_darwin_x86_64"

tool_path { name: "ar" path: "/usr/bin/libtool" }
tool_path { name: "compat-ld" path: "/usr/bin/ld" }
Expand Down
2 changes: 1 addition & 1 deletion tools/cpp/cc_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def cc_autoconf_impl(repository_ctx, overriden_tools = dict()):
# TODO(ibiryukov): overriden_tools are only supported in configure_unix_toolchain.
# We might want to add that to Windows too(at least for msys toolchain).
configure_windows_toolchain(repository_ctx)
elif (cpu_value == "darwin" and
elif (cpu_value == "darwin_x86_64" and
("BAZEL_USE_CPP_ONLY_TOOLCHAIN" not in env or env["BAZEL_USE_CPP_ONLY_TOOLCHAIN"] != "1")):
configure_osx_toolchain(repository_ctx, overriden_tools)
else:
Expand Down
2 changes: 1 addition & 1 deletion tools/cpp/crosstool_lib.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def _is_linux(platform):
return platform == "k8"

def _is_darwin(platform):
return platform == "darwin"
return platform.startswith("darwin")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be able to change this to just darwin_x86_64, I'm not entirely sure, but also if we eventually have to support a new darwin, I assume this is what we'll want


def _is_msvc(platform):
return platform == "msvc"
Expand Down
2 changes: 1 addition & 1 deletion tools/cpp/lib_cc_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def get_cpu_value(repository_ctx):
"""Compute the cpu_value based on the OS name. Doesn't %-escape the result!"""
os_name = repository_ctx.os.name.lower()
if os_name.startswith("mac os"):
return "darwin"
return "darwin_x86_64"
if os_name.find("freebsd") != -1:
return "freebsd"
if os_name.find("windows") != -1:
Expand Down
2 changes: 1 addition & 1 deletion tools/cpp/osx_cc_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@ def configure_osx_toolchain(repository_ctx, overriden_tools):
{"%{cxx_builtin_include_directory}": "\n".join(escaped_cxx_include_directories)},
)
else:
configure_unix_toolchain(repository_ctx, cpu_value = "darwin", overriden_tools = overriden_tools)
configure_unix_toolchain(repository_ctx, cpu_value = "darwin_x86_64", overriden_tools = overriden_tools)
2 changes: 1 addition & 1 deletion tools/cpp/unix_cc_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools):
])

repository_ctx.file("tools/cpp/empty.cc", "int main() {}")
darwin = cpu_value == "darwin"
darwin = cpu_value == "darwin_x86_64"

cc = _find_generic(repository_ctx, "gcc", "CC", overriden_tools)
overriden_tools = dict(overriden_tools)
Expand Down
4 changes: 2 additions & 2 deletions tools/osx/crosstool/BUILD.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ CC_TOOLCHAINS = [(
":cc-compiler-" + cpu,
) for cpu in OSX_TOOLS_ARCHS] + [
("k8|compiler", ":cc-compiler-darwin_x86_64", ),
("darwin|compiler", ":cc-compiler-darwin_x86_64", ),
("darwin_x86_64|compiler", ":cc-compiler-darwin_x86_64", ),
("k8", ":cc-compiler-darwin_x86_64", ),
("darwin", ":cc-compiler-darwin_x86_64", ),
("darwin_x86_64", ":cc-compiler-darwin_x86_64", ),
]

cc_library(
Expand Down