Closed fingolfin closed 2 years ago
Facing the same issue on an M1 MacBook Air, macOS 12.2. XCode 13.2 as well.
Got the same issue and am bisecting, there were also a bunch of warnings added that weren't present before so let's see.
f09099206c7d11ffbe25e3416d504dcbdd3de7ec is the guilty commit according to bisect from #43852. Also a bunch of
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
warnings appeared.
That's not a segfault though, is it?
Indeed it isn't
@fingolfin nice to see you here too :)
I am wondering if this is by design or a rule of thumb about building julia on new hardware (e.g. M1 Macs) or in general --- 1.7.2 works fine (a lot of tests still fail if you attempt run "all"... ) but master branch bombs (I think the error I get is identical to the above)
f090992 is the guilty commit according to bisect from #43852. Also a bunch of
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types] struct { ^
warnings appeared.
Oh noooo, @Keno 😢 I actually tried to build the master branch just to test this PR 😆
I am wondering if this is by design or a rule of thumb about building julia on new hardware (e.g. M1 Macs) or in general
This platforms is currently in Tier 3 of support, this means there is currently no CI for aarch64-apple-darwin, so the failure couldn't be caught during the review of the pull request.
I am wondering if this is by design or a rule of thumb about building julia on new hardware (e.g. M1 Macs) or in general
This platforms is currently in Tier 3 of support, this means there is currently no CI for aarch64-apple-darwin, so the failure couldn't be caught during the review of the pull request.
No, no I understand that --- to clarify, I meant: usually the "tagged" items are like guaranteed, but master isn't it exactly like that since it is not a release. Or do we consider master stable enough as almost like a pseudo-release?
Then again M1 shouldn't be considered stable at all, I guess. But in general for other hardware, master vis-a-vis tags?
Then again M1 shouldn't be considered stable at all, I guess
Who said otherwise?
But in general for other hardware, master vis-a-vis tags?
Not sure what that means.
Then again M1 shouldn't be considered stable at all, I guess
Who said otherwise?
But in general for other hardware, master vis-a-vis tags?
Not sure what that means.
Don't worry about it 😄 I am glad it wasn't just me, hopefully we will be able to test that PR soon since it seemed pretty impressive!
I see many more warnings with the latest commit on master (6c16f717f9871401eed9350f36cd84ab51778b72).
(base) gong@mac julia % make
PERL base/pcre_h.jl
PERL base/errno_h.jl
PERL base/build_h.jl.phony
PERL base/features_h.jl
PERL base/features_h.jl
PERL base/features_h.jl
PERL base/file_constants.jl
PERL base/uv_constants.jl
PERL base/version_git.jl.phony
CC cli/loader_exe.o
CC cli/loader_lib.o
CC cli/loader_trampolines.o
LINK usr/lib/libjulia.1.8.dylib
LINK usr/lib/libjulia.dylib
LINK usr/bin/julia
FLISP src/julia_flisp.boot
FLISP src/julia_flisp.boot.inc
CC src/jloptions.o
CC src/runtime_ccall.o
In file included from /Users/gong/GitHub/julia/src/runtime_ccall.cpp:10:
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
./julia.h:406:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
2 warnings generated.
CC src/rtutils.o
CC src/jltypes.o
CC src/gf.o
CC src/typemap.o
CC src/smallintset.o
CC src/ast.o
CC src/builtins.o
CC src/module.o
CC src/interpreter.o
CC src/symbol.o
CC src/dlload.o
CC src/sys.o
CC src/init.o
CC src/task.o
CC src/array.o
CC src/dump.o
CC src/staticdata.o
/Users/gong/GitHub/julia/src/staticdata.c:1709:33: warning: incompatible function pointer types passing 'void (jl_methtable_t *, void *)' (aka 'void (struct _jl_methtable_t *, void *)') to parameter of type 'int (*)(jl_methtable_t *, void *)' (aka 'int (*)(struct _jl_methtable_t *, void *)') [-Wincompatible-function-pointer-types]
jl_foreach_reachable_mtable(set_nroots_sysimg_, NULL);
^~~~~~~~~~~~~~~~~~
./julia_internal.h:615:39: note: passing argument to parameter 'visit' here
int jl_foreach_reachable_mtable(int (*visit)(jl_methtable_t *mt, void *env), void *env);
^
1 warning generated.
CC src/toplevel.o
CC src/jl_uv.o
CC src/datatype.o
CC src/simplevector.o
CC src/runtime_intrinsics.o
CC src/precompile.o
CC src/threading.o
CC src/partr.o
CC src/stackwalk.o
CC src/gc.o
CC src/gc-debug.o
CC src/gc-pages.o
CC src/gc-stacks.o
CC src/gc-alloc-profiler.o
In file included from /Users/gong/GitHub/julia/src/gc-alloc-profiler.cpp:3:
In file included from ./gc-alloc-profiler.h:6:
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
./julia.h:406:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
2 warnings generated.
CC src/method.o
CC src/jlapi.o
CC src/signal-handling.o
/Users/gong/GitHub/julia/src/signal-handling.c:117:15: warning: unused function 'jl_safe_read_mem' [-Wunused-function]
static size_t jl_safe_read_mem(const volatile char *ptr, char *out, size_t len)
^
1 warning generated.
CC src/safepoint.o
CC src/timing.o
CC src/subtype.o
CC src/crc32c.o
'++crc' is not a recognized feature for this target (ignoring feature)
'++crc' is not a recognized feature for this target (ignoring feature)
CC src/APInt-C.o
In file included from /Users/gong/GitHub/julia/src/APInt-C.cpp:10:
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
./julia.h:406:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
2 warnings generated.
CC src/processor.o
In file included from /Users/gong/GitHub/julia/src/processor.cpp:10:
In file included from ./processor.h:5:
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
./julia.h:406:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
In file included from /Users/gong/GitHub/julia/src/processor.cpp:847:
./processor_arm.cpp:1815:40: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
asm volatile("mrs %0, fpcr" : "=r"(fpcr));
^
./processor_arm.cpp:1815:23: note: use constraint modifier "w"
asm volatile("mrs %0, fpcr" : "=r"(fpcr));
^~
%w0
./processor_arm.cpp:1821:40: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
asm volatile("msr fpcr, %0" :: "r"(fpcr));
^
./processor_arm.cpp:1821:29: note: use constraint modifier "w"
asm volatile("msr fpcr, %0" :: "r"(fpcr));
^~
%w0
4 warnings generated.
CC src/ircode.o
CC src/opaque_closure.o
CC src/codegen-stubs.o
CC src/coverage.o
In file included from /Users/gong/GitHub/julia/src/coverage.cpp:13:
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
./julia.h:406:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
2 warnings generated.
LINK usr/lib/libjulia-internal.1.8.dylib
LINK usr/lib/libjulia-internal.1.dylib
LINK usr/lib/libjulia-internal.dylib
CC src/codegen.o
In file included from /Users/gong/GitHub/julia/src/codegen.cpp:169:
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
./julia.h:406:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
2 warnings generated.
CC src/llvm-ptls.o
In file included from /Users/gong/GitHub/julia/src/llvm-ptls.cpp:26:
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
./julia.h:406:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
2 warnings generated.
CC src/jitlayers.o
In file included from /Users/gong/GitHub/julia/src/jitlayers.cpp:30:
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
./julia.h:406:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
/Users/gong/GitHub/julia/src/jitlayers.cpp:1016:4: warning: #warning is a language extension [-Wpedantic]
# warning "JIT debugging (GDB integration) not available on LLVM < 14.0 (for JITLink)"
^
/Users/gong/GitHub/julia/src/jitlayers.cpp:1016:4: warning: "JIT debugging (GDB integration) not available on LLVM < 14.0 (for JITLink)" [-W#warnings]
4 warnings generated.
CC src/aotcompile.o
In file included from /Users/gong/GitHub/julia/src/aotcompile.cpp:60:
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
./julia.h:406:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
2 warnings generated.
CC src/debuginfo.o
In file included from /Users/gong/GitHub/julia/src/debuginfo.cpp:25:
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
./julia.h:406:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
2 warnings generated.
CC src/disasm.o
In file included from /Users/gong/GitHub/julia/src/disasm.cpp:111:
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
./julia.h:406:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
2 warnings generated.
CC src/llvm-simdloop.o
CC src/llvm-muladd.o
In file included from /Users/gong/GitHub/julia/src/llvm-muladd.cpp:22:
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
./julia.h:406:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
2 warnings generated.
CC src/llvm-final-gc-lowering.o
In file included from /Users/gong/GitHub/julia/src/llvm-final-gc-lowering.cpp:14:
In file included from ./codegen_shared.h:9:
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
./julia.h:406:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
2 warnings generated.
CC src/llvm-pass-helpers.o
In file included from /Users/gong/GitHub/julia/src/llvm-pass-helpers.cpp:15:
In file included from ./codegen_shared.h:9:
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
./julia.h:406:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
2 warnings generated.
CC src/llvm-late-gc-lowering.o
In file included from /Users/gong/GitHub/julia/src/llvm-late-gc-lowering.cpp:31:
In file included from ./codegen_shared.h:9:
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
./julia.h:406:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
2 warnings generated.
CC src/llvm-lower-handlers.o
In file included from /Users/gong/GitHub/julia/src/llvm-lower-handlers.cpp:22:
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
./julia.h:406:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
2 warnings generated.
CC src/llvm-gc-invariant-verifier.o
In file included from /Users/gong/GitHub/julia/src/llvm-gc-invariant-verifier.cpp:28:
In file included from ./codegen_shared.h:9:
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
./julia.h:406:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
2 warnings generated.
CC src/llvm-propagate-addrspaces.o
In file included from /Users/gong/GitHub/julia/src/llvm-propagate-addrspaces.cpp:25:
In file included from ./codegen_shared.h:9:
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
./julia.h:406:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
2 warnings generated.
CC src/llvm-multiversioning.o
In file included from /Users/gong/GitHub/julia/src/llvm-multiversioning.cpp:28:
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
./julia.h:406:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
2 warnings generated.
CC src/llvm-alloc-opt.o
In file included from /Users/gong/GitHub/julia/src/llvm-alloc-opt.cpp:29:
In file included from ./codegen_shared.h:9:
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
./julia.h:406:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
2 warnings generated.
CC src/llvm-alloc-helpers.o
In file included from /Users/gong/GitHub/julia/src/llvm-alloc-helpers.cpp:5:
In file included from ./codegen_shared.h:9:
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
./julia.h:406:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
2 warnings generated.
CC src/cgmemmgr.o
In file included from /Users/gong/GitHub/julia/src/cgmemmgr.cpp:7:
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
./julia.h:406:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
2 warnings generated.
CC src/llvm-remove-addrspaces.o
In file included from /Users/gong/GitHub/julia/src/llvm-remove-addrspaces.cpp:15:
In file included from ./codegen_shared.h:9:
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
./julia.h:406:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
2 warnings generated.
CC src/llvm-remove-ni.o
In file included from /Users/gong/GitHub/julia/src/llvm-remove-ni.cpp:10:
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
./julia.h:406:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
2 warnings generated.
CC src/llvm-julia-licm.o
In file included from /Users/gong/GitHub/julia/src/llvm-julia-licm.cpp:14:
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
./julia.h:406:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
2 warnings generated.
CC src/llvm-demote-float16.o
CC src/llvm-cpufeatures.o
In file included from /Users/gong/GitHub/julia/src/llvm-cpufeatures.cpp:26:
./julia.h:397:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
./julia.h:406:9: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
struct {
^
2 warnings generated.
LINK usr/lib/libjulia-codegen.1.8.dylib
LINK usr/lib/libjulia-codegen.1.dylib
LINK usr/lib/libjulia-codegen.dylib
JULIA usr/lib/julia/corecompiler.ji
Core.Compiler ──── 28.319 seconds
JULIA usr/lib/julia/sys.ji
coreio.jl
exports.jl
essentials.jl
ctypes.jl
gcutils.jl
generator.jl
reflection.jl
options.jl
promotion.jl
tuple.jl
expr.jl
pair.jl
traits.jl
range.jl
error.jl
bool.jl
number.jl
int.jl
operators.jl
pointer.jl
refvalue.jl
refpointer.jl
checked.jl
strings/lazy.jl
indices.jl
array.jl
abstractarray.jl
subarray.jl
views.jl
baseext.jl
ntuple.jl
abstractdict.jl
iddict.jl
idset.jl
iterators.jl
namedtuple.jl
./build_h.jl
./version_git.jl
hashing.jl
rounding.jl
div.jl
float.jl
twiceprecision.jl
complex.jl
rational.jl
multinverses.jl
abstractarraymath.jl
arraymath.jl
simdloop.jl
reduce.jl
reshapedarray.jl
reinterpretarray.jl
bitarray.jl
bitset.jl
multimedia.jl
some.jl
dict.jl
abstractset.jl
set.jl
char.jl
strings/basic.jl
strings/string.jl
strings/substring.jl
osutils.jl
c.jl
io.jl
iobuffer.jl
intfuncs.jl
strings/strings.jl
strings/search.jl
strings/unicode.jl
strings/util.jl
strings/io.jl
regex.jl
pcre.jl
./pcre_h.jl
parse.jl
shell.jl
show.jl
compiler/ssair/show.jl
arrayshow.jl
methodshow.jl
cartesian.jl
multidimensional.jl
broadcast.jl
missing.jl
version.jl
sysinfo.jl
libc.jl
./errno_h.jl
libdl.jl
logging.jl
linked_list.jl
condition.jl
threads.jl
threadingconstructs.jl
atomics.jl
locks-mt.jl
lock.jl
channels.jl
task.jl
threads_overloads.jl
weakkeydict.jl
env.jl
binaryplatforms.jl
cpuid.jl
./features_h.jl
libuv.jl
./uv_constants.jl
asyncevent.jl
iostream.jl
stream.jl
filesystem.jl
path.jl
stat.jl
file.jl
./file_constants.jl
cmd.jl
process.jl
ttyhascolor.jl
secretbuffer.jl
randomdevice.jl
floatfuncs.jl
math.jl
special/cbrt.jl
special/exp.jl
special/hyperbolic.jl
special/trig.jl
special/rem_pio2.jl
special/log.jl
reducedim.jl
accumulate.jl
permuteddimsarray.jl
ordering.jl
sort.jl
fastmath.jl
Enums.jl
gmp.jl
ryu/Ryu.jl
ryu/utils.jl
ryu/shortest.jl
ryu/fixed.jl
ryu/exp.jl
mpfr.jl
combinatorics.jl
irrationals.jl
mathconstants.jl
meta.jl
stacktraces.jl
experimental.jl
opaque_closure.jl
deepcopy.jl
download.jl
summarysize.jl
errorshow.jl
initdefs.jl
threadcall.jl
uuid.jl
pkgid.jl
toml_parser.jl
loading.jl
timing.jl
util.jl
asyncmap.jl
deprecated.jl
docs/basedocs.jl
client.jl
docs/Docs.jl
docs/bindings.jl
docs/utils.jl
Base ───────────── 14.178758 seconds
ArgTools ───────── 2.531217 seconds
Artifacts ──────── 0.063541 seconds
Base64 ─────────── 0.061001 seconds
CRC32c ─────────── 0.005136 seconds
FileWatching ───── 0.065909 seconds
Libdl ──────────── 0.002190 seconds
Logging ────────── 0.022526 seconds
Mmap ───────────── 0.050645 seconds
NetworkOptions ─── 0.068903 seconds
SHA ────────────── 0.108535 seconds
Serialization ──── 0.158214 seconds
Sockets ────────── 0.192383 seconds
Unicode ────────── 0.044128 seconds
DelimitedFiles ─── 0.061432 seconds
LinearAlgebra ──── 5.266818 seconds
Markdown ───────── 0.439116 seconds
Printf ─────────── 0.088090 seconds
Random ─────────── 0.733423 seconds
Tar ────────────── 0.166660 seconds
Dates ──────────── 0.909628 seconds
Distributed ────── 0.440892 seconds
Future ─────────── 0.004470 seconds
InteractiveUtils ─ 0.240830 seconds
LibGit2 ────────── 0.816253 seconds
Profile ────────── 0.274617 seconds
SparseArrays ───── 1.947869 seconds
UUIDs ──────────── 0.010143 seconds
REPL ───────────── 2.122485 seconds
SharedArrays ───── 0.291869 seconds
Statistics ─────── 0.113225 seconds
SuiteSparse ────── 0.901692 seconds
TOML ───────────── 0.042251 seconds
Test ───────────── 0.191280 seconds
LibCURL ────────── 0.239219 seconds
Downloads ──────── 0.194281 seconds
Pkg ────────────── 2.692248 seconds
LazyArtifacts ──── 0.002312 seconds
Stdlibs total ──── 21.570620 seconds
Sysimage built. Summary:
Total ─────── 35.750053 seconds
Base: ─────── 14.178758 seconds 39.6608%
Stdlibs: ──── 21.570620 seconds 60.3373%
JULIA usr/lib/julia/sys-o.a
Generating REPL precompile statements... 36/36
Executing precompile statements... 1966/2010
Precompilation complete. Summary:
Total ─────── 64.233143 seconds
Generation ── 47.976136 seconds 74.6906%
Execution ─── 16.257007 seconds 25.3094%
LLVM ERROR: failed to perform tail call elimination on a call site marked musttail
signal (6): Abort trap: 6
in expression starting at none:0
__pthread_kill at /usr/lib/system/libsystem_kernel.dylib (unknown line)
Allocations: 158354666 (Pool: 158277106; Big: 77560); GC: 159
/bin/sh: line 1: 18314 Abort trap: 6 JULIA_BINDIR=/Users/gong/GitHub/julia/usr/bin WINEPATH="/Users/gong/GitHub/julia/usr/bin;$WINEPATH" /Users/gong/GitHub/julia/usr/bin/julia -O3 -C "apple-a12" --output-o /Users/gong/GitHub/julia/usr/lib/julia/sys-o.a.tmp --startup-file=no --warn-overwrite=yes --sysimage /Users/gong/GitHub/julia/usr/lib/julia/sys.ji /Users/gong/GitHub/julia/contrib/generate_precompile.jl 1
*** This error is usually fixed by running `make clean`. If the error persists, try `make cleanall`. ***
make[1]: *** [/Users/gong/GitHub/julia/usr/lib/julia/sys-o.a] Error 1
make: *** [julia-sysimg-release] Error 2
Looking into this a bit, I used lldb
to figure out that we're crashing while compiling/running this eval in boot.jl
. While googling around, I found this old commit, and that made me suspect the ccall()
in the code chunk currently being compiled. This made me look into the musttail
annotation that gets applied to ccall()
invocations, and so I tried turning that off, which worked around the error:
diff --git a/src/ccall.cpp b/src/ccall.cpp
index 332c057afa..72b0536025 100644
--- a/src/ccall.cpp
+++ b/src/ccall.cpp
@@ -233,8 +233,8 @@ static GlobalVariable *emit_plt_thunk(
else {
// musttail support is very bad on ARM, PPC, PPC64 (as of LLVM 3.9)
// Known failures includes vararg (not needed here) and sret.
-#if (defined(_CPU_X86_) || defined(_CPU_X86_64_) || \
- defined(_CPU_AARCH64_))
+#if (defined(_CPU_X86_) || defined(_CPU_X86_64_))
+ //defined(_CPU_AARCH64_))
// Ref https://bugs.llvm.org/show_bug.cgi?id=47058
// LLVM, as of 10.0.1 emits wrong/worse code when musttail is set
if (!attrs.hasAttrSomewhere(Attribute::ByVal))
I have no idea if this is a long-term solution though, and I have no idea why this would be triggered now.
I saw this bit about musttail in the Clang 13.0.0 release note, is it relevant for this bug?
That note is relevant, I'm just not sure why no other archs get this error, specially aarch64 linux. That ccall specifically was changed in the purity modeling PR. I wonder if it has to do with the differences in ABI that might spook LLVM out.
@staticfloat @gbaraldi @truedichotomy would you expect this change above to matter for the tests? Running Base.runtests(["all"]; ncores=ceil(Int, Sys.CPU_THREADS))
has returned ~[this error for me]~ ~(https://github.com/JuliaLang/julia/pull/43774#issuecomment-1011228499) and~ errors in Pkg (no method matching getindex(::Nothing, ::String)
) and cmdlineargs (Segmentation fault
).
Looks pretty significant (in a good way; previously I had quite a few more tests failing) to me...
(edit: sorry I missed the two errors in cmdlineargs and Pkg; some bits below) (edit: not really sure if this is an error or not: https://github.com/JuliaLang/julia/pull/43774#issuecomment-1011228499)
I wouldn't be surprised if that broke ccall in some places.
I spun up an ampere instance to try it out and it built fine, and it gave none of the anonymous type warnings. I wonder if that is a difference of GCC vs clang. One thing to try out is using a different another clang instead of apple clang to build to see if it makes a difference.
I think the clang thing is a red herring; LLVM is choking on Julia-generated code, not clang-generated code. I think there's something about the LLVM IR that we're generating that is causing the issue. It could be a real problem with our IR, or it could be LLVM being overly-picky, it's hard to say, as I don't know LLVM well enough to track that down.
My guess as to why it doesn't trigger on aarch64 linux is because there are a number of significant differences between the two ever since https://github.com/JuliaLang/julia/commit/955d4271357ecb5614fd5245627786135402b717 was merged.
What I meant about that is that i don't get those warnings anywhere else except apple. However I saw that someone got them on an x86 build so I have no idea. Edit: on latest master the LLVM ERROR changed to a place before what is mentioned in OP it errors in corecompiler.ji
Has anyone tried to build Julia using LLVM 14 to see if it makes any difference?
The JIT code generation for Apple M1 in Julia currently uses a different code path than all other supported architectures (see PR #43664 by @dnadlinger). Most likely this contributes to the issue and is why things work fine everywhere else. The PR by @keno which broke things must might interact differently with JITLink than with the previous code generation.
Hmm, at first glance, I'm not sure how this would relate to JITLink; the code generation itself by and large still uses the same code path, only the linker stage is different. One difference would be the code model setting, but surely that can't be related to this error? Unfortunately, I don't have the bandwidth to look into this right now.
@dnadlinger sorry, what I wrote might be total nonsense: my main goal here was to point out that some things are very different on Apple M1, so it is not that surprising that an issue only occurs there and not elsewhere.
Oh, no, you certainly have a point, it is a significant difference and possibly related. What I meant is that it isn't exactly obvious why JITLink should cause any issue either, as it should only come in after the codegen stage. Depending on how easy the issue is to trigger, it might be interesting to disable JITLink again and see if it still breaks (don't set JL_USE_JITLINK
).
After grepping llvm for the error I found https://github.com/llvm/llvm-project/blob/d1cd64ffdd832220dbe1829c2f09b880be67be31/llvm/test/CodeGen/AArch64/GlobalISel/call-translator-musttail.ll which is suspicious. I don't know llvm enough to understand if our function would fall into that case. The llvm IR of the function that gives the problem is:
define nonnull {} addrspace(10)* @jlplt_ijl_new_codeinst_1127({} addrspace(10)* %0, {} addrspace(10)* %1, {} addrspace(10)* %2, {} addrspace(10)* %3, i32 %4, i64 %5, i64 %6, i8 zeroext %7, i8 zeroext %8, {} addrspace(10)* %9, i8 zeroext %10) {
top:
%11 = load atomic void ()*, void ()** @ccall_ijl_new_codeinst_1126 unordered, align 8
%12 = icmp ne void ()* %11, null
br i1 %12, label %ccall, label %dlsym
dlsym: ; preds = %top
%13 = call void ()* @ijl_load_and_lookup(i8* null, i8* getelementptr inbounds ([17 x i8], [17 x i8]* inttoptr (i64 105553146517520 to [17 x i8]*), i32 0, i32 0), i8** @jl_RTLD_DEFAULT_handle)
store atomic void ()* %13, void ()** @ccall_ijl_new_codeinst_1126 release, align 8
br label %ccall
ccall: ; preds = %dlsym, %top
%14 = phi void ()* [ %11, %top ], [ %13, %dlsym ]
%15 = bitcast void ()* %14 to {} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)*, {} addrspace(10)*, {} addrspace(10)*, i32, i64, i64, i8, i8, {} addrspace(10)*, i8)*
%16 = bitcast {} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)*, {} addrspace(10)*, {} addrspace(10)*, i32, i64, i64, i8, i8, {} addrspace(10)*, i8)* %15 to void ()*
store atomic void ()* %16, void ()** @jlplt_ijl_new_codeinst_1127_got release, align 8
%17 = musttail call nonnull {} addrspace(10)* %15({} addrspace(10)* %0, {} addrspace(10)* %1, {} addrspace(10)* %2, {} addrspace(10)* %3, i32 %4, i64 %5, i64 %6, i8 zeroext %7, i8 zeroext %8, {} addrspace(10)* %9, i8 zeroext %10)
ret {} addrspace(10)* %17
}
and in the pipeline it gets here https://github.com/llvm/llvm-project/blob/c9b36807beaf120f4e06d9da3b7df7625e440825/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp#L6082 which is what throws the error.
The error message has evolved somewhat from the original, here is the latest build error:
(base) gong@mac julia % make
fatal: bad revision '^upstream/master'
fatal: Not a valid object name upstream/master
JULIA usr/lib/julia/corecompiler.ji
LLVM ERROR: failed to perform tail call elimination on a call site marked musttail
signal (6): Abort trap: 6
in expression starting at compiler/bootstrap.jl:10
__pthread_kill at /usr/lib/system/libsystem_kernel.dylib (unknown line)
Allocations: 836107 (Pool: 836053; Big: 54); GC: 1
/bin/sh: line 1: 89473 Abort trap: 6 /Users/gong/GitHub/julia/usr/bin/julia -C "apple-a12" --output-ji /Users/gong/GitHub/julia/usr/lib/julia/corecompiler.ji.tmp --startup-file=no --warn-overwrite=yes -g0 -O0 compiler/compiler.jl
make[1]: *** [/Users/gong/GitHub/julia/usr/lib/julia/corecompiler.ji] Error 134
make: *** [julia-sysimg-ji] Error 2
@staticfloat your solution by removing musttail
from AARCH64 in ccall.cpp
works for me. Just tested it in 1.9.0-DEV.21. I wonder if it's a sufficient fix to do a PR so that Julia 1.8+ will compile on Apple Silicon macs again.
I did the same as @truedichotomy: made the change in ccall.cpp
and tested under macOS 12.2.1 on an M1 Max on branch 1.8.0-beta1.0 of Julia. The results were better than the one posted here.
Just curious as a non cpp person, what's the benefit of cpp tail call optimization for Julia? Is this a critical optimization to have for performance reasons?
Wondered about that, read this which led to this. Shooting in the dark, but I surmise that it becomes an issue for recursive functions and optimization of stack memory allocation. Seems like a must for Lisp. Not sure if this is simply an optimization for Julia or if it holds potential for out-of-memory errors.
So after a quite long session of debugging I found what causes musttail to fail, and that is https://github.com/gbaraldi/llvm-project/blob/5be8ea4bd7b0d66214c22033a7fd298544e65027/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp#L5702-L5707, the ccall fails that check and bugs out. Why does it only fail that in apple I have no idea.
is building current Julia master crashing for anyone else? (i.e. commit aae68a5e030a04f3d4bfc31f4b30c002ddbc52ca, on : macOS 12.2 (21D49) on Apple M1 Max, Xcode 13.2.1).
It builds fine for me on Ubuntu x86.