Skip to content

Commit bc92c00

Browse files
committed
Fix endianness of non-native 128-bit integers
1 parent 07f2116 commit bc92c00

25 files changed

+339
-358
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ jobs:
3737
steps:
3838
- uses: actions/checkout@v3
3939

40-
- uses: actions/checkout@v3
41-
with:
42-
repository: llvm/llvm-project
43-
path: llvm
44-
4540
- name: Install packages
4641
# `llvm-14-tools` is needed to install the `FileCheck` binary which is used for asm tests.
4742
run: sudo apt-get install ninja-build ripgrep llvm-14-tools
@@ -68,9 +63,6 @@ jobs:
6863
echo "LD_LIBRARY_PATH=$(cat gcc_path)" >> $GITHUB_ENV
6964
echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV
7065
71-
- name: Set RUST_COMPILER_RT_ROOT
72-
run: echo "RUST_COMPILER_RT_ROOT="${{ env.workspace }}/llvm/compiler-rt >> $GITHUB_ENV
73-
7466
- name: Cache cargo installed crates
7567
uses: actions/cache@v3
7668
with:

.github/workflows/failures.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ jobs:
2525
steps:
2626
- uses: actions/checkout@v3
2727

28-
- uses: actions/checkout@v3
29-
with:
30-
repository: llvm/llvm-project
31-
path: llvm
32-
3328
- name: Install packages
3429
run: sudo apt-get install ninja-build ripgrep
3530

@@ -55,9 +50,6 @@ jobs:
5550
echo "LD_LIBRARY_PATH=$(cat gcc_path)" >> $GITHUB_ENV
5651
echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV
5752
58-
- name: Set RUST_COMPILER_RT_ROOT
59-
run: echo "RUST_COMPILER_RT_ROOT="${{ env.workspace }}/llvm/compiler-rt >> $GITHUB_ENV
60-
6153
- name: Cache cargo installed crates
6254
uses: actions/cache@v3
6355
with:

.github/workflows/gcc12.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ jobs:
3737
steps:
3838
- uses: actions/checkout@v3
3939

40-
- uses: actions/checkout@v3
41-
with:
42-
repository: llvm/llvm-project
43-
path: llvm
44-
4540
- name: Install packages
4641
# `llvm-14-tools` is needed to install the `FileCheck` binary which is used for asm tests.
4742
run: sudo apt-get install ninja-build ripgrep llvm-14-tools libgccjit-12-dev
@@ -55,9 +50,6 @@ jobs:
5550
echo "LD_LIBRARY_PATH=$(cat gcc_path)" >> $GITHUB_ENV
5651
echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV
5752
58-
- name: Set RUST_COMPILER_RT_ROOT
59-
run: echo "RUST_COMPILER_RT_ROOT="${{ env.workspace }}/llvm/compiler-rt >> $GITHUB_ENV
60-
6153
- name: Cache cargo installed crates
6254
uses: actions/cache@v3
6355
with:

.github/workflows/m68k.yml

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ permissions:
1515
env:
1616
# Enable backtraces for easier debugging
1717
RUST_BACKTRACE: 1
18+
# TODO: remove when confish.sh is removed.
19+
OVERWRITE_TARGET_TRIPLE: m68k-unknown-linux-gnu
1820

1921
jobs:
2022
build:
@@ -26,13 +28,14 @@ jobs:
2628
commands: [
2729
"--mini-tests",
2830
"--std-tests",
29-
"--test-libcore",
30-
"--extended-rand-tests",
31-
"--extended-regex-example-tests",
32-
"--extended-regex-tests",
33-
"--test-successful-rustc --nb-parts 2 --current-part 0",
34-
"--test-successful-rustc --nb-parts 2 --current-part 1",
35-
"--test-failing-rustc",
31+
# TODO(antoyo): fix those on m68k.
32+
#"--test-libcore",
33+
#"--extended-rand-tests",
34+
#"--extended-regex-example-tests",
35+
#"--extended-regex-tests",
36+
#"--test-successful-rustc --nb-parts 2 --current-part 0",
37+
#"--test-successful-rustc --nb-parts 2 --current-part 1",
38+
#"--test-failing-rustc",
3639
]
3740

3841
steps:
@@ -43,11 +46,6 @@ jobs:
4346
4447
- uses: actions/checkout@v3
4548

46-
- uses: actions/checkout@v3
47-
with:
48-
repository: llvm/llvm-project
49-
path: llvm
50-
5149
- name: Download GCC artifact
5250
uses: dawidd6/action-download-artifact@v2
5351
with:
@@ -77,26 +75,23 @@ jobs:
7775
echo "LD_LIBRARY_PATH=$(cat gcc_path)" >> $GITHUB_ENV
7876
echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV
7977
80-
- name: Set RUST_COMPILER_RT_ROOT
81-
run: echo "RUST_COMPILER_RT_ROOT="${{ env.workspace }}/llvm/compiler-rt >> $GITHUB_ENV
82-
8378
- name: Cache cargo installed crates
8479
uses: actions/cache@v3
8580
with:
8681
path: ~/.cargo/bin
8782
key: cargo-installed-crates2-ubuntu-latest
8883

89-
- name: Cache cargo registry
90-
uses: actions/cache@v3
91-
with:
92-
path: ~/.cargo/registry
93-
key: ${{ runner.os }}-cargo-registry2-${{ hashFiles('**/Cargo.lock') }}
84+
#- name: Cache cargo registry
85+
#uses: actions/cache@v3
86+
#with:
87+
#path: ~/.cargo/registry
88+
#key: ${{ runner.os }}-cargo-registry2-${{ hashFiles('**/Cargo.lock') }}
9489

95-
- name: Cache cargo index
96-
uses: actions/cache@v3
97-
with:
98-
path: ~/.cargo/git
99-
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
90+
#- name: Cache cargo index
91+
#uses: actions/cache@v3
92+
#with:
93+
#path: ~/.cargo/git
94+
#key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
10095

10196
- name: Cache cargo target dir
10297
uses: actions/cache@v3
@@ -122,6 +117,7 @@ jobs:
122117
}
123118
EOF
124119
mkdir vm
120+
pwd # TODO: remove
125121
sudo mount debian-m68k.img vm
126122
m68k-unknown-linux-gnu-gcc main.c -o main
127123
sudo cp main vm/home/main
@@ -140,20 +136,16 @@ jobs:
140136
141137
- name: Build
142138
run: |
143-
./y.sh prepare --only-libcore
144-
# TODO: move into prepare command under a flag --cross-patches?
145-
pushd build_sysroot/sysroot_src
146-
git am ../../cross_patches/*.patch
147-
popd
148-
./build.sh
149-
cargo test
139+
./y.sh prepare --only-libcore --cross
140+
./y.sh build --target-triple m68k-unknown-linux-gnu
141+
CG_GCC_TEST_TARGET=m68k-unknown-linux-gnu cargo test
150142
./clean_all.sh
151143
152144
- name: Prepare dependencies
153145
run: |
154146
git config --global user.email "[email protected]"
155147
git config --global user.name "User"
156-
./y.sh prepare
148+
./y.sh prepare --cross
157149
158150
# Compile is a separate step, as the actions-rs/cargo action supports error annotations
159151
- name: Compile
@@ -167,4 +159,4 @@ jobs:
167159

168160
- name: Run tests
169161
run: |
170-
./test.sh --release --clean --build-sysroot
162+
./test.sh --release --clean --build-sysroot ${{ matrix.commands }}

.github/workflows/release.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ jobs:
2626
steps:
2727
- uses: actions/checkout@v3
2828

29-
- uses: actions/checkout@v3
30-
with:
31-
repository: llvm/llvm-project
32-
path: llvm
33-
3429
- name: Install packages
3530
run: sudo apt-get install ninja-build ripgrep
3631

@@ -56,9 +51,6 @@ jobs:
5651
echo "LD_LIBRARY_PATH=$(cat gcc_path)" >> $GITHUB_ENV
5752
echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV
5853
59-
- name: Set RUST_COMPILER_RT_ROOT
60-
run: echo "RUST_COMPILER_RT_ROOT="${{ env.workspace }}/llvm/compiler-rt >> $GITHUB_ENV
61-
6254
- name: Cache cargo installed crates
6355
uses: actions/cache@v3
6456
with:

.github/workflows/stdarch.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ jobs:
2626
steps:
2727
- uses: actions/checkout@v3
2828

29-
- uses: actions/checkout@v3
30-
with:
31-
repository: llvm/llvm-project
32-
path: llvm
33-
3429
- name: Install packages
3530
run: sudo apt-get install ninja-build ripgrep
3631

@@ -70,9 +65,6 @@ jobs:
7065
echo "LD_LIBRARY_PATH=$(cat gcc_path)" >> $GITHUB_ENV
7166
echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV
7267
73-
- name: Set RUST_COMPILER_RT_ROOT
74-
run: echo "RUST_COMPILER_RT_ROOT="${{ env.workspace }}/llvm/compiler-rt >> $GITHUB_ENV
75-
7668
- name: Cache cargo installed crates
7769
uses: actions/cache@v3
7870
with:

Readme.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,6 @@ $ make check-jit RUNTESTFLAGS="-v -v -v jit.exp=jit.dg/test-asm.cc"
5555
$ dirname $(readlink -f `find . -name libgccjit.so`) > gcc_path
5656
```
5757

58-
You also need to set RUST_COMPILER_RT_ROOT:
59-
60-
```bash
61-
$ git clone https://github.com/llvm/llvm-project llvm --depth 1 --single-branch
62-
$ export RUST_COMPILER_RT_ROOT="$PWD/llvm/compiler-rt"
63-
```
64-
6558
Then you can run commands like this:
6659

6760
```bash
@@ -330,9 +323,9 @@ generate it in [gimple.md](./doc/gimple.md).
330323

331324
* Set `TARGET_TRIPLE="m68k-unknown-linux-gnu"` in config.sh.
332325
* Since rustc doesn't support this architecture yet, set it back to `TARGET_TRIPLE="mips-unknown-linux-gnu"` (or another target having the same attributes). Alternatively, create a [target specification file](https://book.avr-rust.com/005.1-the-target-specification-json-file.html) (note that the `arch` specified in this file must be supported by the rust compiler).
326+
* Run `./y.sh prepare --cross` so that the sysroot is patched for the cross-compiling case.
333327
* Set `linker='-Clinker=m68k-linux-gcc'`.
334328
* Set the path to the cross-compiling libgccjit in `gcc_path`.
335-
* Comment the line: `context.add_command_line_option("-masm=intel");` in src/base.rs.
336329
* (might not be necessary) Disable the compilation of libstd.so (and possibly libcore.so?): Remove dylib from build_sysroot/sysroot_src/library/std/Cargo.toml.
337330

338331
If you get the following error:

build_sysroot/build_sysroot.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ if [[ "$1" == "--release" ]]; then
2323
else
2424
sysroot_channel='debug'
2525
# TODO: add flags to simplify the case for cross-compilation.
26-
AR="m68k-unknown-linux-gnu-ar" CC="m68k-unknown-linux-gnu-gcc" cargo build --target $TARGET_TRIPLE
26+
# TODO: or remove them completely if not needed.
27+
#AR="m68k-unknown-linux-gnu-ar" CC="m68k-unknown-linux-gnu-gcc"
28+
cargo build --target $TARGET_TRIPLE
2729
fi
2830

2931
# Copy files to sysroot

build_system/src/build.rs

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::path::Path;
1111
struct BuildArg {
1212
codegen_release_channel: bool,
1313
sysroot_release_channel: bool,
14-
features: Vec<String>,
14+
flags: Vec<String>,
1515
gcc_path: String,
1616
}
1717

@@ -30,12 +30,12 @@ impl BuildArg {
3030
"--release" => build_arg.codegen_release_channel = true,
3131
"--release-sysroot" => build_arg.sysroot_release_channel = true,
3232
"--no-default-features" => {
33-
build_arg.features.push("--no-default-features".to_string());
33+
build_arg.flags.push("--no-default-features".to_string());
3434
}
3535
"--features" => {
3636
if let Some(arg) = args.next() {
37-
build_arg.features.push("--features".to_string());
38-
build_arg.features.push(arg.as_str().into());
37+
build_arg.flags.push("--features".to_string());
38+
build_arg.flags.push(arg.as_str().into());
3939
} else {
4040
return Err(
4141
"Expected a value after `--features`, found nothing".to_string()
@@ -46,6 +46,15 @@ impl BuildArg {
4646
Self::usage();
4747
return Ok(None);
4848
}
49+
"--target-triple" => {
50+
if args.next().is_some() {
51+
// Handled in config.rs.
52+
} else {
53+
return Err(
54+
"Expected a value after `--target-triple`, found nothing".to_string()
55+
);
56+
}
57+
}
4958
arg => return Err(format!("Unknown argument `{}`", arg)),
5059
}
5160
}
@@ -61,6 +70,7 @@ impl BuildArg {
6170
--release-sysroot : Build sysroot in release mode
6271
--no-default-features : Add `--no-default-features` flag
6372
--features [arg] : Add a new feature [arg]
73+
--target-triple [arg] : Set the target triple to [arg]
6474
--help : Show this help
6575
"#
6676
)
@@ -147,8 +157,6 @@ fn build_sysroot(
147157
&"build",
148158
&"--target",
149159
&target_triple,
150-
&"--features",
151-
&"compiler_builtins/c",
152160
],
153161
None,
154162
Some(env),
@@ -175,16 +183,6 @@ fn build_sysroot(
175183
fn build_codegen(args: &BuildArg) -> Result<(), String> {
176184
let mut env = HashMap::new();
177185

178-
let current_dir =
179-
std::env::current_dir().map_err(|error| format!("`current_dir` failed: {:?}", error))?;
180-
if let Ok(rt_root) = std::env::var("RUST_COMPILER_RT_ROOT") {
181-
env.insert("RUST_COMPILER_RT_ROOT".to_string(), rt_root);
182-
} else {
183-
env.insert(
184-
"RUST_COMPILER_RT_ROOT".to_string(),
185-
format!("{}", current_dir.join("llvm/compiler-rt").display()),
186-
);
187-
}
188186
env.insert("LD_LIBRARY_PATH".to_string(), args.gcc_path.clone());
189187
env.insert("LIBRARY_PATH".to_string(), args.gcc_path.clone());
190188

@@ -196,9 +194,9 @@ fn build_codegen(args: &BuildArg) -> Result<(), String> {
196194
} else {
197195
env.insert("CHANNEL".to_string(), "debug".to_string());
198196
}
199-
let ref_features = args.features.iter().map(|s| s.as_str()).collect::<Vec<_>>();
200-
for feature in &ref_features {
201-
command.push(feature);
197+
let flags = args.flags.iter().map(|s| s.as_str()).collect::<Vec<_>>();
198+
for flag in &flags {
199+
command.push(flag);
202200
}
203201
run_command_with_output_and_env(&command, None, Some(&env))?;
204202

build_system/src/config.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,32 @@ pub fn set_config(
3030
};
3131
let host_triple = get_rustc_host_triple()?;
3232
let mut linker = None;
33-
let mut target_triple = host_triple.as_str();
33+
let mut target_triple = host_triple.clone();
3434
let mut run_wrapper = None;
35-
// FIXME: handle this with a command line flag?
36-
// let mut target_triple = "m68k-unknown-linux-gnu";
35+
36+
// We skip binary name and the command.
37+
let mut args = std::env::args().skip(2);
38+
39+
while let Some(arg) = args.next() {
40+
match arg.as_str() {
41+
"--target-triple" => {
42+
if let Some(arg) = args.next() {
43+
target_triple = arg;
44+
} else {
45+
return Err(
46+
"Expected a value after `--target-triple`, found nothing".to_string()
47+
);
48+
}
49+
},
50+
_ => (),
51+
}
52+
}
3753

3854
if host_triple != target_triple {
3955
if target_triple == "m68k-unknown-linux-gnu" {
40-
target_triple = "mips-unknown-linux-gnu";
41-
linker = Some("-Clinker=m68k-linux-gcc");
56+
//target_triple = "mips-unknown-linux-gnu";
57+
// TODO: only add "-gcc" to the target triple instead of having these conditions?
58+
linker = Some("-Clinker=m68k-unknown-linux-gnu-gcc");
4259
} else if target_triple == "aarch64-unknown-linux-gnu" {
4360
// We are cross-compiling for aarch64. Use the correct linker and run tests in qemu.
4461
linker = Some("-Clinker=aarch64-linux-gnu-gcc");

build_system/src/prepare.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ impl PrepareArg {
194194
`prepare` command help:
195195
196196
--only-libcore : Only setup libcore and don't clone other repositories
197+
--cross : Apply the patches needed to do cross-compilation
197198
--help : Show this help
198199
"#
199200
)

0 commit comments

Comments
 (0)