Fix thread safety with LLVM library #340

Merged
sb10q merged 3 commits from fix/llvm-threadsafe into master 2023-10-16 15:56:58 +08:00
Collaborator

It turns out that although NAC3 uses multiple threads for compilation, LLVM_ENABLE_THREADS has been set to OFF all this time, which may explain all the segfaults and other runtime errors that have been reported.

The commit introducing this is from ffe89eec86, which explicitly disables threading. I am not sure why it was set that way to begin with, but if that change is necessary for whatever reason, this PR also contains changes to force single-threaded compilation when LLVM detects that thread-safe mode is disabled at build-time.

It turns out that although NAC3 uses multiple threads for compilation, `LLVM_ENABLE_THREADS` has been set to `OFF` all this time, which may explain all the segfaults and other runtime errors that have been reported. The commit introducing this is from ffe89eec8674b12e2a2e4d5d522a068d27b080fd, which explicitly disables threading. I am not sure why it was set that way to begin with, but if that change is necessary for whatever reason, this PR also contains changes to force single-threaded compilation when LLVM detects that thread-safe mode is disabled at build-time.
derppening self-assigned this 2023-10-13 11:36:17 +08:00
derppening added 3 commits 2023-10-13 11:36:18 +08:00
derppening force-pushed fix/llvm-threadsafe from 2110638bfe to 71e6fd65ab 2023-10-13 15:01:17 +08:00 Compare
derppening force-pushed fix/llvm-threadsafe from 71e6fd65ab to a034844b1a 2023-10-13 15:02:59 +08:00 Compare
derppening changed title from Fix thread safety with LLVM library to WIP: Fix thread safety with LLVM library 2023-10-13 15:03:13 +08:00
derppening added 1 commit 2023-10-13 16:09:51 +08:00
Poster
Collaborator

v2: Rebased against master
v3: Rebased against fix/threading-support; Add dependency on #341
v4: Remove lazy_static dependency

v2: Rebased against master v3: Rebased against `fix/threading-support`; Add dependency on #341 v4: Remove `lazy_static` dependency
sb10q reviewed 2023-10-13 21:17:05 +08:00
@ -54,0 +52,4 @@
llvm-link -o module.bc module*.bc main.bc
else
cp main.bc module.bc
fi

How about replacing this entire block of code with something like llvm-link -o output.bc main.bc module*.bc ?

How about replacing this entire block of code with something like ``llvm-link -o output.bc main.bc module*.bc`` ?
Poster
Collaborator

Unfortunately this will cause llvm-link to fail with No such file or directory.

Unfortunately this will cause `llvm-link` to fail with `No such file or directory`.
Poster
Collaborator

v5: Rebased against fix/threading-support

v5: Rebased against `fix/threading-support`
derppening force-pushed fix/llvm-threadsafe from 557ef1ec79 to c6450befd9 2023-10-16 12:23:10 +08:00 Compare
derppening force-pushed fix/llvm-threadsafe from c6450befd9 to 25affa332e 2023-10-16 13:45:03 +08:00 Compare
Poster
Collaborator

v6: Rebased against fix/threading-support

v6: Rebased against `fix/threading-support`
derppening force-pushed fix/llvm-threadsafe from 25affa332e to eb63698fa5 2023-10-16 14:19:07 +08:00 Compare
Poster
Collaborator

v6: Rebased against fix/threading-support

v6: Rebased against `fix/threading-support`
derppening changed title from WIP: Fix thread safety with LLVM library to Fix thread safety with LLVM library 2023-10-16 15:47:44 +08:00
derppening force-pushed fix/llvm-threadsafe from eb63698fa5 to 73500c9081 2023-10-16 15:55:20 +08:00 Compare
sb10q merged commit 73500c9081 into master 2023-10-16 15:56:55 +08:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Reference: M-Labs/nac3#340
There is no content yet.