Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upWIP FreeBSD/aarch64 support #28171
Conversation
ararslan
added
freebsd
arm
labels
Jul 18, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
ararslan
Jul 18, 2018
Member
still can't finish the build because of crashes. (using llvm 6.0.1 from system)
Note that while we allow building with the system's LLVM, it's highly discouraged, since we rely a lot on the local patches we provide for it; I don't think we guarantee (or even check) that using the system's LLVM provides a working build. So you may have better luck letting Julia build its own.
Note that while we allow building with the system's LLVM, it's highly discouraged, since we rely a lot on the local patches we provide for it; I don't think we guarantee (or even check) that using the system's LLVM provides a working build. So you may have better luck letting Julia build its own. |
ararslan
requested review from
staticfloat and
vchuravy
Jul 18, 2018
vchuravy
requested a review
from
yuyichao
Jul 18, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
vchuravy
Jul 18, 2018
Member
Cool! This looks like you are hitting #27174, best to compile with a debug build of LLVM to get better error messages.
|
Cool! This looks like you are hitting #27174, best to compile with a debug build of LLVM to get better error messages. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
yuyichao
Jul 18, 2018
Member
Clear link register (x29)
Yes I got the two names reversed in task.c, it should be [30].
Yes I got the two names reversed in task.c, it should be |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
yuyichao
Jul 18, 2018
Member
Disabled that, now it builds corecompiler.ji successfully, but building sys.ji crashes:
This will definitely not work.
sys::Memory::InvalidateInstructionCache segfaults the compiler:
What's the instruction it segfaults on?
This will definitely not work.
What's the instruction it segfaults on? |
| # include <sys/auxv.h> | ||
| #else | ||
| # define DYN_GETAUXVAL | ||
| #if defined(__GLIBC_PREREQ) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
| # else | ||
| # define DYN_GETAUXVAL | ||
| # endif | ||
| #elif defined(__FreeBSD__) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
| ifneq (,$(findstring aarch64,$(ARCH))) | ||
| ifeq ($(USECLANG),1) | ||
| ifeq ($(MARCH),) | ||
| JCFLAGS += -mcrc |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
yuyichao
Jul 18, 2018
Member
Does clang not support the target attribute? This is still wrong if it doesn't though since IIUC it'll allow all the code to use the crc extention.
yuyichao
Jul 18, 2018
Member
Does clang not support the target attribute? This is still wrong if it doesn't though since IIUC it'll allow all the code to use the crc extention.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
myfreeweb
Jul 18, 2018
It does, but it doesn't recognize +crc in the target.
Yes, it'll allow all code to use it, but I don't think LLVM would ever use CRC automatically. Is there a good way to set flags per file in your makefile?
myfreeweb
Jul 18, 2018
It does, but it doesn't recognize +crc in the target.
Yes, it'll allow all code to use it, but I don't think LLVM would ever use CRC automatically. Is there a good way to set flags per file in your makefile?
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
myfreeweb
Jul 18, 2018
I mean, I was talking about armv8-a+crc, not bare +crc of course :D
https://bugs.chromium.org/p/chromium/issues/detail?id=554632
Apparently that was "fixed", but I don't know where. Not in regular 6.0.1.
myfreeweb
Jul 18, 2018
I mean, I was talking about armv8-a+crc, not bare +crc of course :D
https://bugs.chromium.org/p/chromium/issues/detail?id=554632
Apparently that was "fixed", but I don't know where. Not in regular 6.0.1.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
yuyichao
Jul 18, 2018
Member
Well, I do see a difference bewteen gcc and clang support of target attribute on arm/aarch64 so sometimes one would work but not the other.
Anyway, just leave it like this with a comment should be OK. Adding flag for a specific file is doable but uglier with little gain and it's not really more correct either.
Another way to fix this would be to use assembler text processing tricks and binary code to generate the assemble as binary directly. Given that there are only very few CPU's that people will run julia on that will not have the crc32 extension I think that's not worth doing...
yuyichao
Jul 18, 2018
Member
Well, I do see a difference bewteen gcc and clang support of target attribute on arm/aarch64 so sometimes one would work but not the other.
Anyway, just leave it like this with a comment should be OK. Adding flag for a specific file is doable but uglier with little gain and it's not really more correct either.
Another way to fix this would be to use assembler text processing tricks and binary code to generate the assemble as binary directly. Given that there are only very few CPU's that people will run julia on that will not have the crc32 extension I think that's not worth doing...
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
yuyichao
Jul 18, 2018
Member
I do have an X-Gene 1 so that's one. I couldn't find a feature set for a35 and the arm page didn't mention crc and I didn't find the manual last time I checked.
yuyichao
Jul 18, 2018
Member
I do have an X-Gene 1 so that's one. I couldn't find a feature set for a35 and the arm page didn't mention crc and I didn't find the manual last time I checked.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
myfreeweb
Jul 20, 2018
Hm, actually — clang is fine with the per function +crc… except there was an extra plus sign in __attribute__((target("+crc"))) — clang adds its own plus and you get ++:
'++crc' is not a recognized feature for this target (ignoring feature)
__attribute__((target("crc"))) seems to work
myfreeweb
Jul 20, 2018
Hm, actually — clang is fine with the per function +crc… except there was an extra plus sign in __attribute__((target("+crc"))) — clang adds its own plus and you get ++:
'++crc' is not a recognized feature for this target (ignoring feature)
__attribute__((target("crc"))) seems to work
| @@ -506,13 +506,15 @@ class ROAllocator { | ||
| virtual ~ROAllocator() {} | ||
| virtual void finalize() | ||
| { | ||
| #ifndef _CPU_AARCH64_ |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
yuyichao
Jul 18, 2018
Member
As mentioned in the comment, this is certainly wrong, if you need this for testing, at least enable it for only freebsd.
yuyichao
Jul 18, 2018
Member
As mentioned in the comment, this is certainly wrong, if you need this for testing, at least enable it for only freebsd.
| @@ -324,6 +324,9 @@ CRC_TARGET static uint32_t crc32c_armv8(uint32_t crc, const char *buf, size_t le | ||
| } | ||
| // HW feature detection | ||
| #ifndef HWCAP_CRC32 |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
myfreeweb
Jul 18, 2018
No, the header doesn't define any features. https://github.com/freebsd/freebsd/blob/master/sys/sys/auxv.h
myfreeweb
Jul 18, 2018
No, the header doesn't define any features. https://github.com/freebsd/freebsd/blob/master/sys/sys/auxv.h
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
yuyichao
Jul 18, 2018
Member
Is this defined anywhere then? It'll also be better to condition this on freebsd, since I don't think these values are universal (it does seem that the freebsd value is the same as the linux one in this case)
yuyichao
Jul 18, 2018
Member
Is this defined anywhere then? It'll also be better to condition this on freebsd, since I don't think these values are universal (it does seem that the freebsd value is the same as the linux one in this case)
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
| ucontext_t *ctx = (ucontext_t*)_ctx; | ||
| ctx->uc_mcontext.mc_gpregs.gp_sp = rsp; | ||
| ctx->uc_mcontext.mc_gpregs.gp_x[29] = 0; // Clear link register (x29) | ||
| ctx->uc_mcontext.mc_gpregs.gp_elr = (uintptr_t)fptr; |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
yuyichao
Jul 18, 2018
Member
OK, I kind of see where it gets its name from.... It's the address you return to after exception?... But seriously?...... Anyway, that's not important for the PR...
yuyichao
Jul 18, 2018
Member
OK, I kind of see where it gets its name from.... It's the address you return to after exception?... But seriously?...... Anyway, that's not important for the PR...
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
myfreeweb
Jul 20, 2018
Compiled bundled llvm (debug mode).
First crash (cache invalidation):
* thread #1, name = 'julia', stop reason = signal SIGSEGV
* frame #0: 0x00000000426e5034 libLLVM-6.0.so`__clear_cache(start=0x0000000048a6ffb0, end=0x0000000048a70124) at clear_cache.c:168
frame #1: 0x0000000041569d08 libLLVM-6.0.so`llvm::sys::Memory::InvalidateInstructionCache(void const*, unsigned long) + 28
frame #2: 0x0000000040252438 libjulia.so.0.7`(anonymous namespace)::DualMapAllocator<true>::finalize() at cgmemmgr.cpp:513
frame #3: 0x0000000040252414 libjulia.so.0.7`(anonymous namespace)::DualMapAllocator<true>::finalize(this=0x0000000048875200) at cgmemmgr.cpp:644
frame #4: 0x0000000040251550 libjulia.so.0.7`(anonymous namespace)::RTDyldMemoryManagerJL::finalizeMemory(this=0x0000000042a4fa00, ErrMsg=<unavailable>) at cgmemmgr.cpp:869
…
libLLVM-6.0.so`__clear_cache:
0x426e5014 <+0>: mrs x8, CTR_EL0
0x426e5018 <+4>: ubfx w10, w8, #16, #4
0x426e501c <+8>: orr w9, wzr, #0x4
0x426e5020 <+12>: lsl w10, w9, w10
0x426e5024 <+16>: neg x11, x10
0x426e5028 <+20>: and x11, x11, x0
0x426e502c <+24>: cmp x11, x1
0x426e5030 <+28>: b.hs 0x1b0c044 ; <+48> at clear_cache.c:171
-> 0x426e5034 <+32>: dc cvau, x11
0x426e5038 <+36>: add x11, x11, x10
0x426e503c <+40>: cmp x11, x1
0x426e5040 <+44>: b.lo 0x1b0c034 ; <+32> at clear_cache.c:168
0x426e5044 <+48>: and w8, w8, #0xf
0x426e5048 <+52>: lsl w8, w9, w8
0x426e504c <+56>: neg x9, x8
0x426e5050 <+60>: and x9, x9, x0
0x426e5054 <+64>: cmp x9, x1
0x426e5058 <+68>: dsb ish
0x426e505c <+72>: b.hs 0x1b0c070 ; <+92> at clear_cache.c:175
0x426e5060 <+76>: ic ivau, x9
0x426e5064 <+80>: add x9, x9, x8
0x426e5068 <+84>: cmp x9, x1
0x426e506c <+88>: b.lo 0x1b0c060 ; <+76> at clear_cache.c:174
0x426e5070 <+92>: isb
0x426e5074 <+96>: ret
(void *) start = 0x0000000048a6ffb0
(void *) end = 0x0000000048a70124
(uint64_t) xstart = 1218903984
(uint64_t) xend = 1218904356
(uint64_t) ctr_el0 = 2219081732
(size_t) dcache_line_size = 64
(uint64_t) addr = 1218904064
(size_t) icache_line_size = <variable not available>
The trampoline crash is not in LLVM, so debug LLVM didn't change anything.
myfreeweb
commented
Jul 20, 2018
|
Compiled bundled llvm (debug mode). First crash (cache invalidation):
The trampoline crash is not in LLVM, so debug LLVM didn't change anything. |
myfreeweb commentedJul 18, 2018
I'm trying to get it to work…
// Clear link register (x29)—lris not x29, it'sgp_lron FreeBSD, IIRC Linux has the register array declared as[31]so it'sregs[30]??)sys::Memory::InvalidateInstructionCachesegfaults the compiler:Disabled that, now it builds
corecompiler.jisuccessfully, but buildingsys.jicrashes: