-
Notifications
You must be signed in to change notification settings - Fork 2
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
Failure to Compile on apple m1 Macos #183
Comments
Hmm. The MacOS version of the C++ standard library seems to not be fully C++20 compliant here: a std::vector of std::variant's really should have default spaceship operators (<=>). You could try writing a custom spaceship operator for StrAlignment to get around this -- remove the = default from auto StrAlignment::operator<=>(const StrAlignment& rhs) const { if (auto cmp2 = s1_position <=> rhs.s1_position; cmp2 != 0) return s2_position <=> rhs.s2_position; |
I'll have a got at it.
Thanks for the quick response
…On Tue, 3 Sept 2024 at 16:05, Thomas Colthurst ***@***.***> wrote:
Hmm. The MacOS version of the C++ standard library seems to not be fully
C++20 compliant here: a std::vector of std::variant's really should have
default spaceship operators (<=>).
You could try writing a custom spaceship operator for StrAlignment to get
around this -- remove the = default from
auto operator<=>(const StrAlignment&) const = default;
in string_alignment.hh and then in string_alignment.cc add
auto StrAlignment::operator<=>(const StrAlignment& rhs) const {
if (auto cmp = cost <=> rhs.cost; cmp != 0)
return cmp;
if (auto cmp2 = s1_position <=> rhs.s1_position; cmp2 != 0)
return cmp2;
return s2_position <=> rhs.s2_position;
}
—
Reply to this email directly, view it on GitHub
<#183 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAX7BVZWJ7WAAJLMMZUNJ63ZUW6ZJAVCNFSM6AAAAABNSAM52OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMRWGYYTMMJQGU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
Bjorn Heijligers
+31620106733
|
I added the operator to the top of the .cc file, I hope that was the
correct place.
It's failing with this:
ERROR:
/Users/datascience/PycharmProjects/github/hierarchical-irm/cxx/emissions/BUILD:109:11:
Compiling emissions/string_alignment.cc failed: (Exit 1): cc_wrapper.sh
failed: error executing CppCompile command (from target
//emissions:string_alignment)
external/bazel_tools~cc_configure_extension~local_config_cc/cc_wrapper.sh
-U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign
-Wunused-but-set-parameter -Wno-free-nonheap-object ... (remaining 28
arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the
sandbox build root for debugging
emissions/string_alignment.cc:10:1: error: 'auto' in return type deduced as
'std::strong_ordering' here but deduced as 'std::partial_ordering' in
earlier return statement
return cmp2;
…On Tue, 3 Sept 2024 at 16:26, Bjorn Heijligers ***@***.***> wrote:
I'll have a got at it.
Thanks for the quick response
On Tue, 3 Sept 2024 at 16:05, Thomas Colthurst ***@***.***>
wrote:
> Hmm. The MacOS version of the C++ standard library seems to not be fully
> C++20 compliant here: a std::vector of std::variant's really should have
> default spaceship operators (<=>).
>
> You could try writing a custom spaceship operator for StrAlignment to get
> around this -- remove the = default from
> auto operator<=>(const StrAlignment&) const = default;
> in string_alignment.hh and then in string_alignment.cc add
>
> auto StrAlignment::operator<=>(const StrAlignment& rhs) const {
> if (auto cmp = cost <=> rhs.cost; cmp != 0)
> return cmp;
>
> if (auto cmp2 = s1_position <=> rhs.s1_position; cmp2 != 0)
> return cmp2;
>
> return s2_position <=> rhs.s2_position;
> }
>
> —
> Reply to this email directly, view it on GitHub
> <#183 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAX7BVZWJ7WAAJLMMZUNJ63ZUW6ZJAVCNFSM6AAAAABNSAM52OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMRWGYYTMMJQGU>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>
--
Bjorn Heijligers
+31620106733
--
Bjorn Heijligers
+31620106733
|
You can try replacing the auto on the line auto StrAlignment::operator<=>(const StrAlignment& rhs) const { with std::partial_ordering. You might have to also add a #include before it. |
Well that at least seemed to work.
I used brew install bazel to install the compiler, yet it looks like there
are more differences
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__random/uniform_int_distribution.h:157:5:
error: static assertion failed due to requirement
'__libcpp_random_is_valid_inttype<char>::value': IntType must be a
supported integer type
static_assert(__libcpp_random_is_valid_inttype<_IntType>::value,
"IntType must be a supported integer type");
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./emissions/simple_string.hh:132:41: note: in instantiation of template
class 'std::uniform_int_distribution<char>' requested here
std::uniform_int_distribution<char> uid(lowest_char, highest_char + 1);
^
1 error generated.
I also had to manually add
#include <numbers> // For std::numbers::pi (C++20 feature)
#include <boost/math/special_functions/bessel.hpp> // Use Boost's
Bessel function
to skellam.c to get around
Use --sandbox_debug to see verbose messages from the sandbox and
retain the sandbox build root for debugging
distributions/skellam.cc:10:58: error: no member named 'numbers' in
namespace 'std'
- std::log(x * stddev) - 0.5 * std::log(2.0 * std::numbers::pi);
~~~~~^
distributions/skellam.cc:16:23: error: no member named 'cyl_bessel_i'
in namespace 'std'
+ std::log(std::cyl_bessel_i(std::abs(x), 2.0 * std::sqrt(mu1 * mu2)));
Modifying char to unsigned char I get stuck on importing boost correctly. I
haven't touched C in 30 years, let alone cpp
I've added to BUILD
cc_library(
name = "skellam",
srcs = ["skellam.cc"],
hdrs = ["skellam.hh"],
deps = [
***@***.***//:boost",
],
includes = ["/opt/homebrew/Cellar/boost/1.86.0/include"],
)
and WORKSPACE
new_local_repository(
name = "boost",
path = "/opt/homebrew/Cellar/boost/1.86.0",
build_file_content = """
cc_library(
name = "boost",
hdrs = glob(["include/boost/**/*.hpp"]),
includes = ["include"],
visibility = ["//visibility:public"],
)
""",
)
My infinite monkeys have been unsuccessful sofar:
(.venv) ***@***.*** cxx % bazel build //distributions:skellam
--sandbox_debug --verbose_failures
INFO: Analyzed target //distributions:skellam (100 packages loaded, 495
targets configured).
ERROR:
/Users/datascience/PycharmProjects/github/hierarchical-irm/cxx/distributions/BUILD:103:11:
Compiling distributions/skellam.cc failed: (Exit 1): sandbox-exec failed:
error executing CppCompile command
(cd
/private/var/tmp/_bazel_datascience/1fc90758b68677eb62c922214733cf0a/sandbox/darwin-sandbox/298/execroot/_main
&& \
exec env - \
***@***.***/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/datascience/.cargo/bin:/opt/homebrew/bin
\
PWD=/proc/self/cwd \
TMPDIR=/var/folders/q1/rml5lvtj7fq0k12w9857t3cw0000gn/T/ \
/usr/bin/sandbox-exec -f
/private/var/tmp/_bazel_datascience/1fc90758b68677eb62c922214733cf0a/sandbox/darwin-sandbox/298/
sandbox.sb
/var/tmp/_bazel_datascience/install/bf62fa6eb60eb3c9ac747cab67f18c21/process-wrapper
'--timeout=0' '--kill_delay=15'
'--stats=/private/var/tmp/_bazel_datascience/1fc90758b68677eb62c922214733cf0a/sandbox/darwin-sandbox/298/stats.out'
external/bazel_tools~cc_configure_extension~local_config_cc/cc_wrapper.sh
-U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign
-Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics
-fno-omit-frame-pointer '-std=c++14' -MD -MF
bazel-out/darwin_arm64-fastbuild/bin/distributions/_objs/skellam/skellam.d
'-frandom-seed=bazel-out/darwin_arm64-fastbuild/bin/distributions/_objs/skellam/skellam.o'
-iquote . -iquote bazel-out/darwin_arm64-fastbuild/bin
'-mmacosx-version-min=14.5' '-std=c++20' -no-canonical-prefixes
-Wno-builtin-macro-redefined '-D__DATE__="redacted"'
'-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c
distributions/skellam.cc -o
bazel-out/darwin_arm64-fastbuild/bin/distributions/_objs/skellam/skellam.o)
distributions/skellam.cc:6:10: fatal error:
'boost/math/special_functions/bessel.hpp' file not found
#include <boost/math/special_functions/bessel.hpp> // Ensure this path is
correct
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Target //distributions:skellam failed to build
INFO: Elapsed time: 0.712s, Critical Path: 0.42s
INFO: 7 processes: 7 internal.
ERROR: Build did NOT complete successfully
(.venv) ***@***.*** cxx %
…On Tue, 3 Sept 2024 at 18:00, Thomas Colthurst ***@***.***> wrote:
You can try replacing the auto on the line
auto StrAlignment::operator<=>(const StrAlignment& rhs) const {
with std::partial_ordering. You might have to also add a
#include
before it.
—
Reply to this email directly, view it on GitHub
<#183 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAX7BV5UUMFGOBGKQX4THV3ZUXMLLAVCNFSM6AAAAABNSAM52OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMRWHA4DSNZYG4>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
Bjorn Heijligers
+31620106733
|
Huh. The cyl_bessel_i function has been part of C++'s standard library since C++17: https://en.cppreference.com/w/cpp/numeric/special_functions/cyl_bessel_i |
I'm trying to follow the instructions on apple m1 macos and am encountering the following compile error
Any guidance?
The text was updated successfully, but these errors were encountered: