Comparar commits
3 Commits
0bee0c799b
...
953c3ad48d
| Autor | SHA1 | Fecha | |
|---|---|---|---|
|
953c3ad48d
|
|||
|
5e7980a770
|
|||
|
5022cfb5ee
|
30
.github/workflows/ci.yml
vendido
30
.github/workflows/ci.yml
vendido
@@ -17,29 +17,28 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
rust: [stable, beta, nightly]
|
rust: [stable, beta, nightly]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rs/toolchain@v1
|
uses: dtolnay/rust-toolchain@stable
|
||||||
with:
|
with:
|
||||||
toolchain: ${{ matrix.rust }}
|
toolchain: ${{ matrix.rust }}
|
||||||
override: true
|
|
||||||
components: rustfmt, clippy
|
components: rustfmt, clippy
|
||||||
|
|
||||||
- name: Cache cargo registry
|
- name: Cache cargo registry
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: ~/.cargo/registry
|
path: ~/.cargo/registry
|
||||||
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
|
||||||
- name: Cache cargo index
|
- name: Cache cargo index
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: ~/.cargo/git
|
path: ~/.cargo/git
|
||||||
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
|
||||||
- name: Cache cargo build
|
- name: Cache cargo build
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: target
|
path: target
|
||||||
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
|
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
|
||||||
@@ -61,19 +60,16 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: test
|
needs: test
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rs/toolchain@v1
|
uses: dtolnay/rust-toolchain@stable
|
||||||
with:
|
|
||||||
toolchain: stable
|
|
||||||
override: true
|
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cargo build --release --verbose
|
run: cargo build --release --verbose
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: alecc-linux-x86_64
|
name: alecc-linux-x86_64
|
||||||
path: target/release/alecc
|
path: target/release/alecc
|
||||||
@@ -86,14 +82,12 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
target: [i686-unknown-linux-gnu, aarch64-unknown-linux-gnu]
|
target: [i686-unknown-linux-gnu, aarch64-unknown-linux-gnu]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rs/toolchain@v1
|
uses: dtolnay/rust-toolchain@stable
|
||||||
with:
|
with:
|
||||||
toolchain: stable
|
targets: ${{ matrix.target }}
|
||||||
override: true
|
|
||||||
target: ${{ matrix.target }}
|
|
||||||
|
|
||||||
- name: Install cross
|
- name: Install cross
|
||||||
run: cargo install cross
|
run: cargo install cross
|
||||||
@@ -102,7 +96,7 @@ jobs:
|
|||||||
run: cross build --release --target ${{ matrix.target }}
|
run: cross build --release --target ${{ matrix.target }}
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: alecc-${{ matrix.target }}
|
name: alecc-${{ matrix.target }}
|
||||||
path: target/${{ matrix.target }}/release/alecc
|
path: target/${{ matrix.target }}/release/alecc
|
||||||
|
|||||||
@@ -98,7 +98,8 @@ fn bench_optimizer(c: &mut Criterion) {
|
|||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let mut prog_copy = black_box(program.clone());
|
let mut prog_copy = black_box(program.clone());
|
||||||
let mut optimizer = Optimizer::new(OptimizationLevel::None);
|
let mut optimizer = Optimizer::new(OptimizationLevel::None);
|
||||||
black_box(optimizer.optimize(&mut prog_copy).unwrap());
|
optimizer.optimize(&mut prog_copy).unwrap();
|
||||||
|
black_box(());
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -106,7 +107,8 @@ fn bench_optimizer(c: &mut Criterion) {
|
|||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let mut prog_copy = black_box(program.clone());
|
let mut prog_copy = black_box(program.clone());
|
||||||
let mut optimizer = Optimizer::new(OptimizationLevel::Moderate);
|
let mut optimizer = Optimizer::new(OptimizationLevel::Moderate);
|
||||||
black_box(optimizer.optimize(&mut prog_copy).unwrap());
|
optimizer.optimize(&mut prog_copy).unwrap();
|
||||||
|
black_box(());
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -114,7 +116,8 @@ fn bench_optimizer(c: &mut Criterion) {
|
|||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let mut prog_copy = black_box(program.clone());
|
let mut prog_copy = black_box(program.clone());
|
||||||
let mut optimizer = Optimizer::new(OptimizationLevel::Aggressive);
|
let mut optimizer = Optimizer::new(OptimizationLevel::Aggressive);
|
||||||
black_box(optimizer.optimize(&mut prog_copy).unwrap());
|
optimizer.optimize(&mut prog_copy).unwrap();
|
||||||
|
black_box(());
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ impl CodeGenerator {
|
|||||||
let stack_space = parameters.len() * 8;
|
let stack_space = parameters.len() * 8;
|
||||||
// Always reserve at least 8 bytes to maintain 16-byte alignment after rbp push
|
// Always reserve at least 8 bytes to maintain 16-byte alignment after rbp push
|
||||||
let min_space = if stack_space == 0 { 8 } else { stack_space };
|
let min_space = if stack_space == 0 { 8 } else { stack_space };
|
||||||
let aligned_space = ((min_space + 15) / 16) * 16; // Round up to 16-byte boundary
|
let aligned_space = min_space.div_ceil(16) * 16; // Round up to 16-byte boundary
|
||||||
self.emit_line(&format!(" sub rsp, {}", aligned_space));
|
self.emit_line(&format!(" sub rsp, {}", aligned_space));
|
||||||
|
|
||||||
// Store parameters from registers (x86_64 calling convention)
|
// Store parameters from registers (x86_64 calling convention)
|
||||||
@@ -1267,7 +1267,7 @@ impl CodeGenerator {
|
|||||||
|
|
||||||
match self.target {
|
match self.target {
|
||||||
Target::I386 | Target::Amd64 => {
|
Target::I386 | Target::Amd64 => {
|
||||||
self.emit_line(&format!(" test eax, eax"));
|
self.emit_line(" test eax, eax");
|
||||||
self.emit_line(&format!(" {} {}", instruction, label));
|
self.emit_line(&format!(" {} {}", instruction, label));
|
||||||
}
|
}
|
||||||
Target::Arm64 => {
|
Target::Arm64 => {
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ impl Compiler {
|
|||||||
let preprocessed = self.preprocess(&source, input_file).await?;
|
let preprocessed = self.preprocess(&source, input_file).await?;
|
||||||
fs::write(&output_path, preprocessed)
|
fs::write(&output_path, preprocessed)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| AleccError::IoError(e))?;
|
.map_err(AleccError::IoError)?;
|
||||||
return Ok(output_path);
|
return Ok(output_path);
|
||||||
} else {
|
} else {
|
||||||
self.preprocess(&source, input_file).await?
|
self.preprocess(&source, input_file).await?
|
||||||
@@ -149,7 +149,7 @@ impl Compiler {
|
|||||||
let output_path = self.get_output_path(input_file, "s")?;
|
let output_path = self.get_output_path(input_file, "s")?;
|
||||||
fs::write(&output_path, assembly)
|
fs::write(&output_path, assembly)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| AleccError::IoError(e))?;
|
.map_err(AleccError::IoError)?;
|
||||||
return Ok(output_path);
|
return Ok(output_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +157,7 @@ impl Compiler {
|
|||||||
let asm_path = self.create_temp_file("s")?;
|
let asm_path = self.create_temp_file("s")?;
|
||||||
fs::write(&asm_path, assembly)
|
fs::write(&asm_path, assembly)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| AleccError::IoError(e))?;
|
.map_err(AleccError::IoError)?;
|
||||||
|
|
||||||
// Assemble
|
// Assemble
|
||||||
let obj_path = self.assemble_file(&asm_path).await?;
|
let obj_path = self.assemble_file(&asm_path).await?;
|
||||||
@@ -215,9 +215,9 @@ impl Compiler {
|
|||||||
// Skip malformed include
|
// Skip malformed include
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if trimmed.starts_with("#define") {
|
} else if let Some(stripped) = trimmed.strip_prefix("#define") {
|
||||||
// Handle #define (simplified)
|
// Handle #define (simplified)
|
||||||
let parts: Vec<&str> = trimmed[7..].split_whitespace().collect();
|
let parts: Vec<&str> = stripped.split_whitespace().collect();
|
||||||
if !parts.is_empty() {
|
if !parts.is_empty() {
|
||||||
let key = parts[0].to_string();
|
let key = parts[0].to_string();
|
||||||
let value = if parts.len() > 1 {
|
let value = if parts.len() > 1 {
|
||||||
@@ -330,17 +330,17 @@ impl Compiler {
|
|||||||
|
|
||||||
match self.target {
|
match self.target {
|
||||||
Target::I386 => {
|
Target::I386 => {
|
||||||
command.args(&["--32"]);
|
command.args(["--32"]);
|
||||||
}
|
}
|
||||||
Target::Amd64 => {
|
Target::Amd64 => {
|
||||||
command.args(&["--64"]);
|
command.args(["--64"]);
|
||||||
}
|
}
|
||||||
Target::Arm64 => {
|
Target::Arm64 => {
|
||||||
// Default options for aarch64
|
// Default options for aarch64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
command.args(&[
|
command.args([
|
||||||
"-o",
|
"-o",
|
||||||
&obj_path.to_string_lossy(),
|
&obj_path.to_string_lossy(),
|
||||||
&asm_file.to_string_lossy(),
|
&asm_file.to_string_lossy(),
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ impl Linker {
|
|||||||
Ok(command)
|
Ok(command)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_standard_startup_files(&self, _command: &mut Vec<String>) -> Result<()> {
|
fn add_standard_startup_files(&self, _command: &mut [String]) -> Result<()> {
|
||||||
// Skip startup files when we have our own _start
|
// Skip startup files when we have our own _start
|
||||||
// This prevents conflicts with our custom _start implementation
|
// This prevents conflicts with our custom _start implementation
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -257,7 +257,7 @@ impl Linker {
|
|||||||
fn get_gcc_lib_path(&self) -> Result<String> {
|
fn get_gcc_lib_path(&self) -> Result<String> {
|
||||||
// Try to find GCC library path
|
// Try to find GCC library path
|
||||||
let output = Command::new("gcc")
|
let output = Command::new("gcc")
|
||||||
.args(&["-print-libgcc-file-name"])
|
.args(["-print-libgcc-file-name"])
|
||||||
.output()
|
.output()
|
||||||
.map_err(|e| AleccError::LinkerError {
|
.map_err(|e| AleccError::LinkerError {
|
||||||
message: format!("Failed to find GCC library path: {}", e),
|
message: format!("Failed to find GCC library path: {}", e),
|
||||||
|
|||||||
Referencia en una nueva incidencia
Block a user