Skip to content
This repository was archived by the owner on Jun 10, 2024. It is now read-only.

Commit b9d6934

Browse files
committed
fix: firefly on linux
1 parent c4be60f commit b9d6934

File tree

11 files changed

+56
-40
lines changed

11 files changed

+56
-40
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,28 +69,28 @@ instructions for below; but we also produce prebuilt packages that have everythi
6969

7070
##### Installing Prebuilt Distributions (Recommended)
7171

72-
###### Linux
72+
###### Linux (x86_64)
7373

7474
The instructions below reference `$XDG_DATA_HOME` as an environment variable, it
7575
is recommended to export XDG variables in general, but if you have not, just
7676
replace the usages of `$XDG_DATA_HOME` below with `$HOME/.local/share`, which is
7777
the usual default for this XDG variable.
7878

79-
mkdir -p $XDG_DATA_HOME/llvm/
80-
cd $XDG_DATA_HOME/llvm/
81-
wget https://github.com/lumen/llvm-project/releases/download/firefly-15.0.0-dev_2022-07-22/clang+llvm-15.0.0-x86_64-linux-gnu.tar.gz
79+
mkdir -p $XDG_DATA_HOME/llvm/firefly
80+
cd $XDG_DATA_HOME/llvm/firefly
81+
wget https://github.com/getfirefly/llvm-project/releases/download/firefly-15.0.0-dev_2022-08-27/clang+llvm-15.0.0-x86_64-linux-gnu.tar.gz
8282
tar -xz --strip-components 1 -f clang+llvm-15.0.0-x86_64-linux-gnu.tar.gz
8383
rm clang+llvm-15.0.0-x86_64-linux-gnu.tar.gz
8484
cd -
8585

86-
###### MacOS
86+
###### MacOS (arm64)
8787

88-
mkdir -p $XDG_DATA_HOME/llvm/
88+
mkdir -p $XDG_DATA_HOME/llvm/firefly
8989
cd $XDG_DATA_HOME/llvm/
90-
wget https://github.com/lumen/llvm-project/releases/download/firefly-15.0.0-dev_2022-07-22/clang+llvm-15.0.0-x86_64-apple-darwin21.5.0.tar.gz
91-
tar -xzf clang+llvm-15.0.0-x86_64-apple-darwin21.5.0.tar.gz
92-
rm clang+llvm-15.0.0-x86_64-apple-darwin21.5.0.tar.gz
93-
mv clang+llvm-15.0.0-x86_64-apple-darwin21.5.0 firefly
90+
wget https://github.com/GetFirefly/llvm-project/releases/download/firefly-15.0.0-dev_2022-08-27/clang+llvm-15.0.0-arm64-apple-darwin21.6.0.tar.gz
91+
tar -xzf clang+llvm-15.0.0-x86_64-apple-darwin21.6.0.tar.gz
92+
rm clang+llvm-15.0.0-x86_64-apple-darwin21.6.0.tar.gz
93+
mv clang+llvm-15.0.0-x86_64-apple-darwin21.6.0 firefly
9494
cd -
9595

9696
###### Other

compiler/codegen/src/meta.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ impl ProjectInfo {
180180
]);
181181
} else if target_os == "linux" && target_env == "uclibc" {
182182
platform_libs.extend_from_slice(&[("dl", NativeLibraryKind::Unspecified)]);
183+
} else if target_os == "linux" && target_env == "gnu" {
184+
platform_libs.extend_from_slice(&[
185+
("m", NativeLibraryKind::Unspecified),
186+
("dl", NativeLibraryKind::Unspecified),
187+
("pthread", NativeLibraryKind::Unspecified),
188+
]);
183189
}
184190

185191
for (name, kind) in platform_libs.drain(..) {

compiler/llvm/build.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,10 @@ fn main() {
114114
}
115115

116116
if let Ok(mut sanitizer) = env::var(ENV_LLVM_USE_SANITIZER) {
117-
sanitizer.make_ascii_lowercase();
118-
cfg.flag(&format!("-fsanitize={}", sanitizer));
117+
if !sanitizer.is_empty() {
118+
sanitizer.make_ascii_lowercase();
119+
cfg.flag(&format!("-fsanitize={}", sanitizer));
120+
}
119121
}
120122

121123
if env::var_os("LLVM_NDEBUG").is_some() {

compiler/mlir/c_src/include/CIR-c/BinaryEntrySpecifier.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#pragma once
22

3-
#include <cstdlib>
3+
#include <stdint.h>
44

55
#ifdef __cplusplus
6+
#include <cstdlib>
7+
68
namespace mlir {
79
namespace cir {
810
enum class BinaryEntrySpecifierType : uint32_t {

compiler/mlir/c_src/lib/Extensions/SymbolTable.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ static inline MlirVisibility wrap(mlir::SymbolTable::Visibility v) {
2828
switch (v) {
2929
case mlir::SymbolTable::Visibility::Public:
3030
return MlirVisibilityPublic;
31-
case mlir::SymbolTable::Visibility::Private:
32-
return MlirVisibilityPrivate;
3331
case mlir::SymbolTable::Visibility::Nested:
3432
return MlirVisibilityNested;
33+
case mlir::SymbolTable::Visibility::Private:
34+
default:
35+
return MlirVisibilityPrivate;
3536
}
3637
}
3738

library/rt/src/backtrace/trace.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ impl Trace {
3939
#[cfg(feature = "std")]
4040
pub fn capture() -> Arc<Self> {
4141
// Allocates a new trace on the heap
42-
let trace_arc = Self::new(Vec::with_capacity(Self::MAX_FRAMES));
43-
let ptr = Arc::as_ptr(&trace_arc) as *mut Trace;
44-
let trace = unsafe { &mut *ptr };
42+
let mut trace_arc = Self::new(Vec::with_capacity(Self::MAX_FRAMES));
43+
let trace = unsafe { Arc::get_mut_unchecked(&mut trace_arc) };
4544
//let stackmap = StackMap::get();
4645

4746
// Capture the raw metadata for each frame in the trace

library/rt/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#![feature(const_type_id)]
2525
// Used for NonNull::as_uninit_mut
2626
#![feature(ptr_as_uninit)]
27+
// Used for Arc::get_mut_unchecked
28+
#![feature(get_mut_unchecked)]
2729
// The following are used for the Tuple implementation
2830
#![feature(trusted_len)]
2931
#![feature(slice_index_methods)]

runtimes/tiny/src/scheduler/swap_stack/swap_stack_linux_x86_64.s

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,20 @@ __firefly_swap_stack:
8787
.cfi_def_cfa rbp, 16
8888
.cfi_offset rbp, -16
8989

90-
# Now that the frames are linked, we can call the entry point. For now, this
91-
# is __firefly_trap_exceptions, which expects to receive two arguments: the function
92-
# being wrapped by the exception handler, and the value of the closure environment,
93-
# _if_ it is a closure being called, otherwise the value of that argument is Term::NONE
90+
# Now that the frames are linked, we can call the entry point.
91+
# The only argument is the value of the closure environment (or Term::NONE if not a closure)
9492
mov rdi, r12
95-
96-
# We have already set up the stack precisely, so we don't use callq here, instead
97-
# we go ahead and jump straight to the beginning of the entry function.
98-
# NOTE: This call never truly returns, as the exception handler calls __firefly_builtin_exit
99-
# with the return value of the 'real' entry function, or with an exception if one
100-
# is caught. However, swap_stack _does_ return for all other swaps, just not the first.
10193
call r14
94+
95+
# When we return to this point, the process has fully unwound and should exit, returning
96+
# back to the scheduler. We handle this by calling __firefly_builtin_exit, which sets up the
97+
# process status, and then yields to the scheduler. Control never returns here, so we hint
98+
# as such by which branch instruction we use
99+
#
100+
# NOTE: The ErlangResult struct will have been saved in rax/rdx, so we must move it to rdi/rsi
101+
# to reflect passing it by value as the sole argument to the __firefly_builtin_exit intrinsic
102+
mov rax, rdi
103+
mov rdx, rsi
102104
jmp __firefly_builtin_exit
103105

104106
.L_resume:

runtimes/tiny/src/scheduler/swap_stack/swap_stack_macos_x86_64.s

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,20 @@ ___firefly_swap_stack:
8585
.cfi_def_cfa rbp, 16
8686
.cfi_offset rbp, -16
8787

88-
# Now that the frames are linked, we can call the entry point. For now, this
89-
# is __firefly_trap_exceptions, which expects to receive two arguments: the function
90-
# being wrapped by the exception handler, and the value of the closure environment,
91-
# _if_ it is a closure being called, otherwise the value of that argument is Term::NONE
88+
# Now that the frames are linked, we can call the entry point.
89+
# The only argument is the value of the closure environment (or Term::NONE if not a closure)
9290
mov rdi, r12
93-
94-
# We have already set up the stack precisely, so we don't use call here, instead
95-
# we go ahead and jump straight to the beginning of the entry function.
96-
# NOTE: This call never truly returns, as the exception handler calls __firefly_builtin_exit
97-
# with the return value of the 'real' entry function, or with an exception if one
98-
# is caught. However, swap_stack _does_ return for all other swaps, just not the first.
9991
call r14
92+
93+
# When we return to this point, the process has fully unwound and should exit, returning
94+
# back to the scheduler. We handle this by calling __firefly_builtin_exit, which sets up the
95+
# process status, and then yields to the scheduler. Control never returns here, so we hint
96+
# as such by which branch instruction we use
97+
#
98+
# NOTE: The ErlangResult struct will have been saved in rax/rdx, so we must move it to rdi/rsi
99+
# to reflect passing it by value as the sole argument to the __firefly_builtin_exit intrinsic
100+
mov rax, rdi
101+
mov rdx, rsi
100102
jmp ___firefly_builtin_exit
101103

102104
L_resume:

tools/firefly-make/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)