google / riegeli

Riegeli/records is a file format for storing a sequence of string records, typically serialized protocol buffers.
Apache License 2.0
418 stars 53 forks source link

Expected to work on M1? #29

Closed jsphweid closed 9 months ago

jsphweid commented 9 months ago

Is this expected to build on Mac M1?

When using riegeli, it seems to have issues compiling highwayhash.

ld: warning: ignoring duplicate libraries: '-lc++', '-lm', '-lpthread'
ld: Undefined symbols:
  highwayhash::HighwayHash<16u>::operator()(unsigned long long const (&) [4], char const*, unsigned long, unsigned long long*) const, referenced from:
      unsigned int highwayhash::InstructionSets::Run<highwayhash::HighwayHash, unsigned long long const (&) [4], char const*, unsigned long, unsigned long long*>(unsigned long long const (&) [4], char const*&&, unsigned long&&, unsigned long long*&&) in libhash.a[2](hash.o)
  highwayhash::HighwayHashCat<16u>::operator()(unsigned long long const (&) [4], highwayhash::StringView const*, unsigned long, unsigned long long*) const, referenced from:
      unsigned int highwayhash::InstructionSets::Run<highwayhash::HighwayHashCat, unsigned long long const (&) [4], highwayhash::StringView*, unsigned long, unsigned long long*>(unsigned long long const (&) [4], highwayhash::StringView*&&, unsigned long&&, unsigned long long*&&) in libhash.a[2](hash.o)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error in child process '/usr/bin/xcrun'. 1
external/local_config_cc/cc_wrapper.sh: line 69: 25217 Abort trap: 6           "$(/usr/bin/dirname "$0")"/wrapped_clang "$@"

I have no issues on my x86 ubuntu machine. But the above is what I get on mac. I'm not immediately sure why it can't find these definitions, although I suspect it has to do with some potential weirdness in highwayhash.BUILD -- something with highwayhash/highwayhash_target.cc where I believe those definitions are located -- it's being included in textual_hdrs which seems odd (ex. https://github.com/google/riegeli/blob/master/third_party/highwayhash.BUILD#L178).

Would be curious if anyone else on M1 has this issue.

jan-wassenberg commented 9 months ago

Hi, it indeed looks like the build file is not deciding to include the hh_neon target. We base this on "@platforms//cpu:arm64": [],. I'm not very familiar with Bazel's platform detection; is there something else we should be checking for M1?

jsphweid commented 9 months ago

Thanks for the quick response. I'm not too familiar with this stuff either outside vanilla usage. Here's what I found.

If I change "aarch64" here to "darwin_arm64" instead, it works. I think that's what I'll do. I'm not immediately sure whether this is a general problem or one somehow related to my setup.

I found I could also define that config_setting with constraint_values instead in which case ["@platforms//cpu:aarch64"], ["@platforms//cpu:arm64"] and probably others work as well.

Potentially related: https://github.com/bazelbuild/bazel/issues/15175.

jan-wassenberg commented 9 months ago

Thanks for letting us know :)