Skip to content

Conversation

@avsm
Copy link

@avsm avsm commented Apr 6, 2025

#=== ERROR while compiling base.v0.17.1 =======================================#
# context     2.3.0 | macos/arm64 | ocaml-base-compiler.5.3.0 | git+file:///Users/avsm/src/git/ocaml/opam-repository
# path        ~/.opam/5.3.0/.opam-switch/build/base.v0.17.1
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p base -j 15
# exit-code   1
# env-file    ~/.opam/log/base-69125-3e5a5a.env
# output-file ~/.opam/log/base-69125-3e5a5a.out
### output ###
# [...]
# (cd _build/default/src && /usr/bin/cc -O2 -fno-strict-aliasing -fwrapv -pthread -D_FILE_OFFSET_BITS=64 -fdiagnostics-color=always -D_LARGEFILE64_SOURCE -mpopcnt -g -I /Users/avsm/.opam/5.3.0/lib/ocaml -I /Users/avsm/.opam/5.3.0/lib/ocaml_intrinsics_kernel -I /Users/avsm/.opam/5.3.0/lib/sexplib0 -I ../hash_types/src -I ../shadow-stdlib/src -o am_testing.o -c am_testing.c)
# clang: error: unsupported option '-mpopcnt' for target 'arm64-apple-darwin24.4.0'

The problem arises from this bug in clang
llvm/llvm-project#116278 which causes the following:

$ cc t.c -mpopcnt
clang: error: unsupported option '-mpopcnt' for target 'arm64-apple-darwin24.4.0'
$ cc t.c -mpopcnt -lpthread

The src/discover uses dune configurator, which always appends the C link flags from ocamlopt to the command line, and so the configurator erronously thinks that -mpopcnt will work.

Since the dune configurator can't easily be overridden, this PR works around this specific link order issue by hand-calling the cc compiler from the discover binary.

fixes #164 and #168

The problem arises from this bug in clang
llvm/llvm-project#116278
which causes the following:

```
$ cc t.c -mpopcnt
clang: error: unsupported option '-mpopcnt' for target 'arm64-apple-darwin24.4.0'
$ cc t.c -mpopcnt -lpthread
```

The src/discover uses dune configurator, which always appends
the C link flags from ocamlopt to the command line, and so the
configurator erronously thinks that -mpopcnt will work.

Since the dune configurator can't easily be overridden, this
PR works around this specific link order issue by hand-calling
the cc compiler from the discover binary.

fixes janestreet#164 and janestreet#168
avsm added a commit to avsm/opam-repository that referenced this pull request Apr 6, 2025
@github-iron github-iron added the forwarded-to-js-devs This report has been forwarded to Jane Street's internal review system. label Apr 7, 2025
@dkalinichenko-js dkalinichenko-js merged commit 00bcbd1 into janestreet:v0.17 Apr 7, 2025
1 check failed
vouillon added a commit to ocaml-wasm/base that referenced this pull request Sep 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

forwarded-to-js-devs This report has been forwarded to Jane Street's internal review system.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants