bazelbuild / platforms

Constraint values for specifying platforms and toolchains
Apache License 2.0
108 stars 71 forks source link

Add amd64 arch #43

Open mexicarne opened 2 years ago

mexicarne commented 2 years ago

In FreeBSD x86_64 is known as amd64

~% uname -p amd64

google-cla[bot] commented 2 years ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

mexicarne commented 1 year ago

In FreeBSD x86_64 is known as amd64

Yeech. I think this needs some discussion. For most people x86_64 == amd64. I don't want to force toolchain authors to now have to account amd64 just to work on freebsd. Perhaps the right thing to do is have bazel do the mapping to x86_64 correctly.

Can you clarify what problem you are trying to solve by adding this? Have you tried other workarounds to not having it? Have you tried with amd64 as an alias to x86_64, rather than a distinct label.

Sorry for delay. My point to introduce this change is to allow natively build projects with bazel on FreeBSD. For example, I'm trying to build python binding for selenium (https://github.com/SeleniumHQ/selenium) like this:

~/Downloads/selenium-trunk% bazel build //py:selenium
Starting local Bazel server and connecting to it...
INFO: Repository python_toolchain instantiated at:
  /usr/home/user/Downloads/selenium-trunk/WORKSPACE:71:27: in <toplevel>
  /usr/home/user/.cache/bazel/_bazel_user/fa3feb297ac7d465d01b5b481c081747/external/rules_python/python/repositories.bzl:320:34: in python_register_toolchains
Repository rule resolved_interpreter_os_alias defined at:
  /usr/home/user/.cache/bazel/_bazel_user/fa3feb297ac7d465d01b5b481c081747/external/rules_python/python/private/toolchains_repo.bzl:124:48: in <toplevel>
ERROR: An error occurred during the fetch of repository 'python_toolchain':
   Traceback (most recent call last):
    File "/usr/home/user/.cache/bazel/_bazel_user/fa3feb297ac7d465d01b5b481c081747/external/rules_python/python/private/toolchains_repo.bzl", line 81, column 13, in _resolved_interpreter_os_alias_impl
        fail("No platform declared for host OS {} on arch {}".format(os_name, arch))
Error in fail: No platform declared for host OS freebsd on arch amd64
ERROR: /usr/home/user/Downloads/selenium-trunk/WORKSPACE:71:27: fetching resolved_interpreter_os_alias rule //external:python_toolchain: Traceback (most recent call last):
    File "/usr/home/user/.cache/bazel/_bazel_user/fa3feb297ac7d465d01b5b481c081747/external/rules_python/python/private/toolchains_repo.bzl", line 81, column 13, in _resolved_interpreter_os_alias_impl
        fail("No platform declared for host OS {} on arch {}".format(os_name, arch))
Error in fail: No platform declared for host OS freebsd on arch amd64
ERROR: no such package '@python_toolchain//': No platform declared for host OS freebsd on arch amd64
INFO: Elapsed time: 2.924s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)

I traced it to bazel-paltforms, that has no mention of amd64. I believe you are right that it should be an alias instead.

thesayyn commented 1 year ago

This could be an alias instead like https://github.com/bazelbuild/platforms/blob/829cd4bc1a34331947b794ed3b20577984481dde/cpu/BUILD#L35-L38