Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 6 additions & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ jobs:

test-linux:
name: Test Linux
runs-on: ubuntu-latest
runs-on: ${{ matrix.config.os }}
strategy:
matrix:
config:
- { os: "ubuntu-latest" }
- { os: "ubuntu-24.04-arm" }
container: ghcr.io/plc-lang/rust-llvm:latest
steps:
- uses: actions/checkout@v3
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/lit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ on:
jobs:
lit-linux-debug:
name: lit tests (Linux, debug build)
runs-on: ubuntu-latest
runs-on: ${{ matrix.config.os }}
strategy:
matrix:
config:
- { os: "ubuntu-latest" }
- { os: "ubuntu-24.04-arm" }
container: ghcr.io/plc-lang/rust-llvm:latest
steps:
- uses: actions/checkout@v3
Expand All @@ -25,11 +30,16 @@ jobs:
lit-linux-release:
name: lit tests (Linux, release build)
runs-on: ubuntu-latest
strategy:
matrix:
config:
- { os: "ubuntu-latest" }
- { os: "ubuntu-24.04-arm" }
container: ghcr.io/plc-lang/rust-llvm:latest
steps:
- uses: actions/checkout@v3

- name: Run `build.sh --lit --release`
shell: bash
run: |
./scripts/build.sh --lit --release
./scripts/build.sh --lit --release
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ plc_util = { path = "./compiler/plc_util" }
plc_diagnostics = { path = "./compiler/plc_diagnostics" }
plc_index = { path = "./compiler/plc_index" }
section_mangler = { path = "./compiler/section_mangler" }
plc_llvm = { path = "./compiler/plc_llvm" }
logos = "0.12.0"
clap = { version = "3.0", features = ["derive"] }
indexmap = "2.0"
Expand All @@ -31,6 +32,7 @@ regex = "1"
shell-words = "1.1.0"
plc_derive = { path = "./compiler/plc_derive" }
lld_rs = { git = "https://github.com/mun-lang/lld-rs", rev = "3798ace" }

which = "4.2.5"
log.workspace = true
inkwell.workspace = true
Expand Down Expand Up @@ -79,6 +81,7 @@ members = [
"compiler/plc_index",
"compiler/section_mangler",
"compiler/plc_lowering",
"compiler/plc_llvm",
"tests/test_utils",
]
default-members = [".", "compiler/plc_driver", "compiler/plc_xml"]
Expand Down
2 changes: 1 addition & 1 deletion compiler/plc_driver/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ pub struct CompileParameters {
name = "no-linker-script",
long,
global = true,
group = "linker_script",
help = "Specify that no linker script should be used"
)]
#[deprecated = "Does nothing"]
pub no_linker_script: bool,

#[clap(
Expand Down
3 changes: 2 additions & 1 deletion compiler/plc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ pub struct LinkOptions {

#[derive(Clone, Default, Debug)]
pub enum LinkerScript {
#[default]
#[deprecated = "No longer used, the default build script is enough"]
Builtin,
Path(String),
#[default]
None,
}

Expand Down
30 changes: 3 additions & 27 deletions compiler/plc_driver/src/pipelines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use ast::{
};

use itertools::Itertools;
use log::debug;
use participant::{PipelineParticipant, PipelineParticipantMut};
use plc::{
codegen::{CodegenContext, GeneratedModule},
Expand Down Expand Up @@ -51,7 +50,6 @@ use rayon::prelude::*;
use source_code::{source_location::SourceLocation, SourceContainer};

use serde_json;
use tempfile::NamedTempFile;
use toml;

pub mod participant;
Expand Down Expand Up @@ -203,11 +201,7 @@ impl<T: SourceContainer> BuildPipeline<T> {

library_paths.extend_from_slice(self.project.get_library_paths());
//Get the specified linker script or load the default linker script in a temp file
let linker_script = if params.no_linker_script {
LinkerScript::None
} else {
params.linker_script.clone().map(LinkerScript::Path).unwrap_or_default()
};
let linker_script = params.linker_script.clone().map(LinkerScript::Path).unwrap_or_default();

LinkOptions {
libraries,
Expand Down Expand Up @@ -983,29 +977,11 @@ impl GeneratedProject {
//HACK: Create a temp file that would contain the bultin linker script
//FIXME: This has to be done regardless if the file is used or not because it has
//to be in scope by the time we call the linker
let mut file = NamedTempFile::new()?;
match link_options.linker_script {
LinkerScript::Builtin => {
let target = self.target.get_target_triple().to_string();
//Only do this on linux systems
if target.contains("linux") {
if target.contains("x86_64") {
let content = include_str!("../../../scripts/linker/x86_64.script");
writeln!(file, "{content}")?;
linker.set_linker_script(file.get_location_str().to_string());
} else if target.contains("aarch64") {
let content = include_str!("../../../scripts/linker/aarch64.script");
writeln!(file, "{content}")?;
linker.set_linker_script(file.get_location_str().to_string());
} else {
debug!("No script for target : {target}");
}
} else {
debug!("No script for target : {target}");
}
}
LinkerScript::Path(script) => linker.set_linker_script(script),
LinkerScript::None => {}
#[allow(deprecated)]
LinkerScript::Builtin => {}
};

match link_options.format {
Expand Down
10 changes: 5 additions & 5 deletions compiler/plc_driver/src/tests/external_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn external_file_function_call() {
//Given a program calling a function from an external file
let prog = SourceCode::new(
"
FUNCTION main : INT
FUNCTION main : DINT
external();
END_FUNCTION
",
Expand All @@ -18,7 +18,7 @@ fn external_file_function_call() {

let ext = SourceCode::new(
"
FUNCTION external : INT
FUNCTION external : DINT
END_FUNCTION
",
"external.st",
Expand All @@ -34,7 +34,7 @@ fn external_file_global_var() {
//Given a program calling a function from an external file
let prog = SourceCode::new(
"
FUNCTION main : INT
FUNCTION main : DINT
x := 2;
y := 2;
external();
Expand All @@ -48,7 +48,7 @@ fn external_file_global_var() {
VAR_GLOBAL
x : INT;
END_VAR
FUNCTION external : INT
FUNCTION external : DINT
END_FUNCTION
VAR_GLOBAL
y : INT;
Expand All @@ -67,7 +67,7 @@ fn calling_external_file_function_without_including_file_results_in_error() {
//Given a program calling a function from an external file
let prog = SourceCode::new(
"
FUNCTION main : INT
FUNCTION main : DINT
external();
END_FUNCTION
",
Expand Down
8 changes: 4 additions & 4 deletions compiler/plc_driver/src/tests/multi_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn multiple_source_files_generated() {
//Given 2 sources
let src1 = SourceCode::new(
"
FUNCTION main : INT
FUNCTION main : DINT
VAR_INPUT

END_VAR
Expand Down Expand Up @@ -45,7 +45,7 @@ fn multiple_files_with_debug_info() {
//Given 2 sources
let src1: SourceCode = SourceCode::new(
"
FUNCTION main : INT
FUNCTION main : DINT
VAR_INPUT

END_VAR
Expand Down Expand Up @@ -84,7 +84,7 @@ fn multiple_files_in_different_locations_with_debug_info() {
//Given 2 sources
let src1: SourceCode = SourceCode::new(
"
FUNCTION main : INT
FUNCTION main : DINT
VAR_INPUT

END_VAR
Expand Down Expand Up @@ -125,7 +125,7 @@ fn forward_declared_constant_is_also_marked_constant() {
// and the other with the definition of that constant.
let src1 = SourceCode::new(
"
FUNCTION main : INT
FUNCTION main : DINT
VAR
f: foo;
END_VAR
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
---
source: compiler/plc_driver/./src/tests/external_files.rs
source: compiler/plc_driver/src/tests/external_files.rs
expression: "results.join(\"\\n\")"
snapshot_kind: text
---
; ModuleID = 'main.st'
source_filename = "main.st"
target datalayout = "[filtered]"
target triple = "[filtered]"

define i16 @main() {
define i32 @main() {
entry:
%main = alloca i16, align 2
store i16 0, i16* %main, align 2
%call = call i16 @external()
%main_ret = load i16, i16* %main, align 2
ret i16 %main_ret
%main = alloca i32, align [filtered]
store i32 0, i32* %main, align [filtered]
%call = call i32 @external()
%main_ret = load i32, i32* %main, align [filtered]
ret i32 %main_ret
}

declare i16 @external()
declare i32 @external()

; ModuleID = 'external.st'
source_filename = "external.st"
target datalayout = "[filtered]"
target triple = "[filtered]"

declare i16 @external()
declare i32 @external()

; ModuleID = '__init___TestProject'
source_filename = "__init___TestProject"
target datalayout = "[filtered]"
target triple = "[filtered]"

@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @__init___TestProject, i8* null }]
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__init___TestProject, i8* null }]

define void @__init___TestProject() {
entry:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
source: compiler/plc_driver/./src/tests/external_files.rs
source: compiler/plc_driver/src/tests/external_files.rs
expression: "results.join(\"\\n\")"
snapshot_kind: text
---
; ModuleID = 'main.st'
source_filename = "main.st"
Expand All @@ -11,18 +10,18 @@ target triple = "[filtered]"
@x = external global i16
@y = external global i16

define i16 @main() {
define i32 @main() {
entry:
%main = alloca i16, align 2
store i16 0, i16* %main, align 2
store i16 2, i16* @x, align 2
store i16 2, i16* @y, align 2
%call = call i16 @external()
%main_ret = load i16, i16* %main, align 2
ret i16 %main_ret
%main = alloca i32, align [filtered]
store i32 0, i32* %main, align [filtered]
store i16 2, i16* @x, align [filtered]
store i16 2, i16* @y, align [filtered]
%call = call i32 @external()
%main_ret = load i32, i32* %main, align [filtered]
ret i32 %main_ret
}

declare i16 @external()
declare i32 @external()

; ModuleID = 'external.st'
source_filename = "external.st"
Expand All @@ -32,14 +31,14 @@ target triple = "[filtered]"
@x = external global i16
@y = external global i16

declare i16 @external()
declare i32 @external()

; ModuleID = '__init___TestProject'
source_filename = "__init___TestProject"
target datalayout = "[filtered]"
target triple = "[filtered]"

@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @__init___TestProject, i8* null }]
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__init___TestProject, i8* null }]

define void @__init___TestProject() {
entry:
Expand Down
Loading
Loading