Skip to content

Commit 7cd7a1b

Browse files
giordanosunho
andauthored
Enable JITLink in aarch64 linux. (#49745)
* Enable JITLink in aarch64 linux. * Simplify logic to enable JITLink * Do not enable JITLink on Aarch64 Linux with LLVM < 15 * Add NEWS entry and mention JITLink memory bug in ARM devdocs --------- Co-authored-by: Sunho Kim <[email protected]>
1 parent 061401e commit 7cd7a1b

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Compiler/Runtime improvements
2727

2828
* The `@pure` macro is now deprecated. Use `Base.@assume_effects :foldable` instead ([#48682]).
2929
* The mark phase of the Garbage Collector is now multi-threaded ([#48600]).
30+
* [JITLink](https://llvm.org/docs/JITLink.html) is enabled by default on Linux aarch64 when Julia is linked to LLVM 15 or later versions ([#49745]).
31+
This should resolve many segmentation faults previously observed on this platform.
3032

3133
Command-line option changes
3234
---------------------------

doc/src/devdocs/build/arm.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ Compilation on `ARMv8-A` requires that `Make.user` is configured as follows:
6868
MCPU=armv8-a
6969
```
7070

71+
Starting from Julia v1.10, [JITLink](https://llvm.org/docs/JITLink.html) is automatically enabled on this architecture for all operating systems when linking to LLVM 15 or later versions.
72+
Due to a [bug in LLVM memory manager](https://github.com/llvm/llvm-project/issues/63236), non-trivial workloads may generate too many memory mappings that on Linux can exceed the limit of memory mappings (`mmap`) set in the file `/proc/sys/vm/max_map_count`, resulting in an error like
73+
```
74+
JIT session error: Cannot allocate memory
75+
```
76+
Should this happen, ask your system administrator to increase the limit of memory mappings for example with the command
77+
```
78+
sysctl -w vm.max_map_count=262144
79+
```
80+
7181
### nVidia Jetson TX2
7282

7383
Julia builds and runs on the [nVidia Jetson TX2](https://www.nvidia.com/object/embedded-systems-dev-kits-modules.html)

src/jitlayers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ class JLDebuginfoPlugin : public ObjectLinkingLayer::Plugin {
807807
PassConfig.PostAllocationPasses.push_back([&Info, this](jitlink::LinkGraph &G) -> Error {
808808
std::lock_guard<std::mutex> lock(PluginMutex);
809809
for (const jitlink::Section &Sec : G.sections()) {
810-
#ifdef _OS_DARWIN_
810+
#if defined(_OS_DARWIN_)
811811
// Canonical JITLink section names have the segment name included, e.g.
812812
// "__TEXT,__text" or "__DWARF,__debug_str". There are some special internal
813813
// sections without a comma separator, which we can just ignore.

src/jitlayers.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,24 @@
4141
// However, JITLink is a relatively young library and lags behind in platform
4242
// and feature support (e.g. Windows, JITEventListeners for various profilers,
4343
// etc.). Thus, we currently only use JITLink where absolutely required, that is,
44-
// for Mac/aarch64.
44+
// for Mac/aarch64 and Linux/aarch64.
4545
// #define JL_FORCE_JITLINK
4646

4747
#if defined(_COMPILER_ASAN_ENABLED_) || defined(_COMPILER_MSAN_ENABLED_) || defined(_COMPILER_TSAN_ENABLED_)
4848
# define HAS_SANITIZER
4949
#endif
5050
// The sanitizers don't play well with our memory manager
5151

52-
#if defined(_OS_DARWIN_) && defined(_CPU_AARCH64_) || defined(JL_FORCE_JITLINK) || JL_LLVM_VERSION >= 150000 && defined(HAS_SANITIZER)
52+
#if defined(JL_FORCE_JITLINK) || JL_LLVM_VERSION >= 150000 && defined(HAS_SANITIZER)
5353
# define JL_USE_JITLINK
54+
#else
55+
# if defined(_CPU_AARCH64_)
56+
# if defined(_OS_LINUX_) && JL_LLVM_VERSION < 150000
57+
# pragma message("On aarch64-gnu-linux, LLVM version >= 15 is required for JITLink; fallback suffers from occasional segfaults")
58+
# else
59+
# define JL_USE_JITLINK
60+
# endif
61+
# endif
5462
#endif
5563

5664
#ifdef JL_USE_JITLINK

0 commit comments

Comments
 (0)