Define CAMLunreachable in GCC < 10#13331
Conversation
|
Miod Vallat (2024/07/24 01:33 -0700):
@dustanddreams approved this pull request.
> @@ -382,7 +382,9 @@ CAMLexport int caml_ba_compare(value v1, value v2)
case CAML_BA_CAML_INT:
case CAML_BA_NATIVE_INT:
DO_INTEGER_COMPARISON(intnat);
- default: CAMLunreachable();
+ default: /* Should not happen */
+ CAMLunreachable();
+ return 0; /* Keeps GCC -Wall happy */
Maybe mention `GCC 9` rather than simply `GCC`, so that next time
someone wonders whether this line is still needed, that person can
check whether gcc 9 is still in use somewhere and able to build the
current OCaml codebase.
Thanks for both the PR and the review. Just approved. Good to go once
the suggestion above has been taken into account and CI passes.
|
|
I would like to understand a bit more what is going on here:
|
f50fbc6 to
b782724
Compare
|
I had a look myself:
|
|
GCC 9 doesn't have |
oh, missed that, thanks |
|
This suggests the following:
|
|
We're already using |
GCC 10 introduced support for __has_builtin. GCC 9 needs a return in all (switch) branches. GCC 4.3 introduced support for __builtin_trap. As for other builtins, we need a fallback to use them with GCC < 10.
|
Yep, our configure requires (gcc >= 4.9), so it would suffice to check |
b782724 to
26e1886
Compare
CAMLunreachable in GCC < 10
|
This looks good, do I correctly understand that you tested the new approach on gcc 9? |
|
We may still have an issue with older compilers or compilers that do not have |
|
(Note: I'm fine with merging the PR as-is, which fixes the immediate issue with gcc 9, and letting you cook up a longer-term fix for the fallback case separately.) |
From LLVM
Older compilers are less of a problem because they tend not to support C11 atomics. For compilers not supporting |
|
I merged the current PR because it is well-scoped, and presumably this will make @nojb's life easier. I would be interested in experiments with |
Thanks! |
(and I confirm that OCaml is again buildable on Ubuntu 20.04) |
This also reverts commit 034f273.Tested
in Ubuntu 20.04with GCC 9 in a Docker image.Reported by @nojb in #13242 (comment).
cc @gasche