Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace cli flag --prebuilt-platform with --build-host #6859

Open
wants to merge 68 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
68 commits
Select commit Hold shift click to select a range
dc0902b
WIP
lukewilliamboswell Jul 2, 2024
753cfb4
fix: building valgrind surgical host
lukewilliamboswell Jul 9, 2024
85447ec
replace stray strings with impl on Target
lukewilliamboswell Jul 9, 2024
96c559e
minor fixes
lukewilliamboswell Jul 9, 2024
4ccbc41
replace gen-stub-lib in nix CI tests
lukewilliamboswell Jul 9, 2024
287d00d
remove gen_stub_lib
lukewilliamboswell Jul 9, 2024
f515311
clippy fix
lukewilliamboswell Jul 9, 2024
bd68787
add --build-host for benchmark tests
lukewilliamboswell Jul 9, 2024
61a5a0a
checkpoint: refactor prebuilt host artifacts
r-bar Jul 9, 2024
d747cc9
Merge remote-tracking branch 'remotes/luke/rebuild-platform' into reb…
r-bar Jul 9, 2024
dfa3254
checkpoint: it compiles
r-bar Jul 11, 2024
bc29782
checkpoint: Run struct refactor for helpers
r-bar Jul 22, 2024
89d63f2
Fix ownership issues with runners
smores56 Aug 14, 2024
3662c90
WIP get things compiling... hacks everywhere beware
lukewilliamboswell Aug 15, 2024
4ec213a
Get tests working
smores56 Aug 15, 2024
550bade
Merge branch 'main' into rebuild-platform
smores56 Aug 15, 2024
49f5ea8
Merge branch 'main' into rebuild-platform
smores56 Aug 15, 2024
28ceb0e
Fix formatting and clippy issues
smores56 Aug 15, 2024
2928969
restore one test
lukewilliamboswell Aug 15, 2024
6276cc7
WIP more cli_run tests passing
lukewilliamboswell Aug 15, 2024
4863234
Merge branch 'rebuild-platform' of github.com:roc-lang/roc into rebui…
lukewilliamboswell Aug 15, 2024
014514a
WIP more passing roc_cli tests
lukewilliamboswell Aug 15, 2024
64cc816
WIP all the roc_cli tests passing, woo
lukewilliamboswell Aug 15, 2024
9ecb209
add suppress warning flag, remove test test_roc_app_slim
lukewilliamboswell Aug 16, 2024
0767115
WIP refactor to build test platform once per test run
lukewilliamboswell Aug 16, 2024
804cb6e
WIP upgrade cli test packages fixture tests
lukewilliamboswell Aug 16, 2024
c8522c2
WIP upgrade cli tests transitive-deps
lukewilliamboswell Aug 16, 2024
d2fbf86
format test files, upgrade some tests
lukewilliamboswell Aug 16, 2024
7ce9ecd
WIP improve cli tests
lukewilliamboswell Aug 16, 2024
894e4d1
make clippy happy again
lukewilliamboswell Aug 16, 2024
5c8eb4f
rename cli to basic-cli
lukewilliamboswell Aug 16, 2024
6ab0de1
fix benchmark tests
lukewilliamboswell Aug 16, 2024
0256c4e
move false interpreter into cli tests
lukewilliamboswell Aug 16, 2024
8ad8198
move effects cli test
lukewilliamboswell Aug 16, 2024
fa40166
move tui example into cli tests
lukewilliamboswell Aug 16, 2024
c3785a2
fix more tests
lukewilliamboswell Aug 16, 2024
767ec7a
cli run tests passing on macos
lukewilliamboswell Aug 16, 2024
ac78d39
Merge remote-tracking branch 'remote/main' into rebuild-platform
lukewilliamboswell Aug 17, 2024
8612220
fix plumbing for roc_glue
lukewilliamboswell Aug 18, 2024
b0c1d88
Merge remote-tracking branch 'remote/main' into rebuild-platform
lukewilliamboswell Aug 18, 2024
e7a90f1
fix clippy
lukewilliamboswell Aug 18, 2024
cd955fd
remove check_compile_error, fix cli tests
lukewilliamboswell Aug 18, 2024
93a4c58
fix cli tests - mainly wasm and i386
lukewilliamboswell Aug 18, 2024
0e917be
add LEGACY LINKER conditional for test runs
lukewilliamboswell Aug 18, 2024
4e6178c
move valgrind configuration into Run builder
lukewilliamboswell Aug 18, 2024
f92974c
use legacy linker in tests
lukewilliamboswell Aug 18, 2024
012a2fc
Merge remote-tracking branch 'remote/main' into rebuild-platform
lukewilliamboswell Sep 3, 2024
a11f51a
fixup
lukewilliamboswell Sep 3, 2024
ec8f6e8
clippy fix
Anton-4 Sep 3, 2024
251e1ed
misc improvements
Anton-4 Sep 3, 2024
ef87653
migrate cli test combine-tasks.roc off basic-cli
lukewilliamboswell Sep 4, 2024
c6a67c9
remove basic-cli tests from roc_cli
lukewilliamboswell Sep 4, 2024
5dfcdae
migrate inspect-logging.roc into cli tests and use effects platform
lukewilliamboswell Sep 4, 2024
73846ed
add test for module_params pass_task.roc
lukewilliamboswell Sep 4, 2024
beb2dcb
remove unneeded basic-cli reference in formatting test
lukewilliamboswell Sep 4, 2024
bb57c4a
remove unneded basic-cli reference in test_reporting
lukewilliamboswell Sep 4, 2024
dc138b8
remove last usage of basic-cli platform from the tests
lukewilliamboswell Sep 4, 2024
03a2d36
fix surgical linking
Anton-4 Oct 8, 2024
e3afeaa
WIP Merge remote-tracking branch 'remote/main' into rebuild-platform
lukewilliamboswell Oct 8, 2024
81668e6
move roc_cli tests to use insta snapshots
lukewilliamboswell Oct 8, 2024
8b8db29
restore module_params cli tests
lukewilliamboswell Oct 8, 2024
de9491e
Merge remote-tracking branch 'remote/main' into rebuild-platform
lukewilliamboswell Oct 8, 2024
61d4ceb
fix input 'rust-overlay' has an override for a non-existent input 'fl…
lukewilliamboswell Oct 8, 2024
57c0f0d
fix can test tip message
lukewilliamboswell Oct 9, 2024
3bad18d
refactoring progress, use valgrind on exe
Anton-4 Oct 9, 2024
0659abd
cli tests refactoring progress
Anton-4 Oct 11, 2024
7dfa469
stuck on Only 64bit little endian elf currently...
Anton-4 Oct 12, 2024
a12d281
fix 'Only 64bit little endian...' with prebuilt platform
Anton-4 Oct 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove gen_stub_lib
  • Loading branch information
lukewilliamboswell committed Jul 9, 2024
commit 287d00df85babfbad00b5090e0c2014aff38857a
2 changes: 1 addition & 1 deletion .github/workflows/nix_macos_apple_silicon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 40,7 @@ jobs:
run: nix develop -c ./ci/roc_test_builtins.sh

- name: make a libapp.so for the next step
run: nix develop -c cargo run -- gen-stub-lib examples/platform-switching/rocLovesRust.roc
run: nix develop -c cargo run -- build --lib examples/platform-switching/rust-platform/libapp.roc

- name: check that the platform`s produced dylib is loadable
run: cd examples/platform-switching/rust-platform && nix develop -c cargo test --release --locked
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nix_macos_x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 24,7 @@ jobs:
run: nix develop -c ./ci/roc_test_builtins.sh

- name: make a libapp.so for the next step
run: nix develop -c cargo run -- gen-stub-lib examples/platform-switching/rocLovesRust.roc
run: nix develop -c cargo run -- build --lib examples/platform-switching/rust-platform/libapp.roc

- name: check that the platform`s produced dylib is loadable
run: cd examples/platform-switching/rust-platform && nix develop -c cargo test --release --locked
18 changes: 0 additions & 18 deletions crates/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 54,6 @@ pub const CMD_VERSION: &str = "version";
pub const CMD_FORMAT: &str = "format";
pub const CMD_TEST: &str = "test";
pub const CMD_GLUE: &str = "glue";
pub const CMD_GEN_STUB_LIB: &str = "gen-stub-lib";
pub const CMD_PREPROCESS_HOST: &str = "preprocess-host";

pub const FLAG_EMIT_LLVM_IR: &str = "emit-llvm-ir";
Expand Down Expand Up @@ -388,23 387,6 @@ pub fn build_app() -> Command {
.default_value(DEFAULT_ROC_FILENAME)
)
)
.subcommand(Command::new(CMD_GEN_STUB_LIB)
.about("Generate a stubbed shared library that can be used for linking a platform binary.\nThe stubbed library has prototypes, but no function bodies.\n\nNote: This command will be removed in favor of just using `roc build` once all platforms support the surgical linker")
.arg(
Arg::new(ROC_FILE)
.help("The .roc file for an app using the platform")
.value_parser(value_parser!(PathBuf))
.required(true)
)
.arg(
Arg::new(FLAG_TARGET)
.long(FLAG_TARGET)
.help("Choose a different target")
.default_value(Into::<&'static str>::into(Target::default()))
.value_parser(build_target_values_parser.clone())
.required(false),
)
)
.subcommand(Command::new(CMD_PREPROCESS_HOST)
.about("Runs the surgical linker preprocessor to generate `.rh` and `.rm` files.")
.arg(
Expand Down
23 changes: 4 additions & 19 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 4,10 @@ use roc_build::link::LinkType;
use roc_build::program::{check_file, CodeGenBackend};
use roc_cli::{
build_app, format_files, format_src, test, BuildConfig, FormatMode, CMD_BUILD, CMD_CHECK,
CMD_DEV, CMD_DOCS, CMD_FORMAT, CMD_GEN_STUB_LIB, CMD_GLUE, CMD_PREPROCESS_HOST, CMD_REPL,
CMD_RUN, CMD_TEST, CMD_VERSION, DIRECTORY_OR_FILES, FLAG_CHECK, FLAG_DEV, FLAG_LIB, FLAG_MAIN,
FLAG_NO_LINK, FLAG_OUTPUT, FLAG_PP_DYLIB, FLAG_PP_HOST, FLAG_PP_PLATFORM, FLAG_STDIN,
FLAG_STDOUT, FLAG_TARGET, FLAG_TIME, GLUE_DIR, GLUE_SPEC, ROC_FILE,
CMD_DEV, CMD_DOCS, CMD_FORMAT, CMD_GLUE, CMD_PREPROCESS_HOST, CMD_REPL, CMD_RUN, CMD_TEST,
CMD_VERSION, DIRECTORY_OR_FILES, FLAG_CHECK, FLAG_DEV, FLAG_LIB, FLAG_MAIN, FLAG_NO_LINK,
FLAG_OUTPUT, FLAG_PP_DYLIB, FLAG_PP_HOST, FLAG_PP_PLATFORM, FLAG_STDIN, FLAG_STDOUT,
FLAG_TARGET, FLAG_TIME, GLUE_DIR, GLUE_SPEC, ROC_FILE,
};
use roc_docs::generate_docs_html;
use roc_error_macros::user_error;
Expand Down Expand Up @@ -120,21 120,6 @@ fn main() -> io::Result<()> {
Ok(1)
}
}
Some((CMD_GEN_STUB_LIB, matches)) => {
let input_path = matches.get_one::<PathBuf>(ROC_FILE).unwrap();
let target = matches
.get_one::<String>(FLAG_TARGET)
.and_then(|s| Target::from_str(s).ok())
.unwrap_or_default();
let function_kind = FunctionKind::from_env();
roc_linker::generate_stub_lib(
input_path,
RocCacheDir::Persistent(cache::roc_cache_dir().as_path()),
target,
function_kind,
);
Ok(0)
}
Some((CMD_PREPROCESS_HOST, matches)) => {
let preprocess_host_err =
{ |msg: String| user_error!("\n\n ERROR PRE-PROCESSING HOST: {}\n\n", msg) };
Expand Down
63 changes: 0 additions & 63 deletions crates/linker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,69 54,6 @@ pub fn link_preprocessed_host(
surgery(roc_app_bytes, &metadata, binary_path, false, false, target)
}

// Exposed function to load a platform file and generate a stub lib for it.
pub fn generate_stub_lib(
input_path: &Path,
roc_cache_dir: RocCacheDir<'_>,
target: Target,
function_kind: FunctionKind,
) -> (PathBuf, PathBuf, Vec<String>) {
// Note: this should theoretically just be able to load the host, I think.
// Instead, I am loading an entire app because that was simpler and had example code.
// If this was expected to stay around for the the long term, we should change it.
// But hopefully it will be removable once we have surgical linking on all platforms.
let arena = &bumpalo::Bump::new();
let loaded = roc_load::load_and_monomorphize(
arena,
input_path.to_path_buf(),
None,
roc_cache_dir,
LoadConfig {
target,
function_kind,
render: RenderTarget::Generic,
palette: DEFAULT_PALETTE,
threading: Threading::AllAvailable,
exec_mode: ExecutionMode::Executable,
},
)
.unwrap_or_else(|problem| todo!("{:?}", problem));

let exposed_to_host = loaded
.exposed_to_host
.top_level_values
.keys()
.map(|x| x.as_str(&loaded.interns).to_string())
.collect();

let exported_closure_types = loaded
.exposed_to_host
.closure_types
.iter()
.map(|x| {
format!(
"{}_{}",
x.module_string(&loaded.interns),
x.as_str(&loaded.interns)
)
})
.collect();

let exposed_symbols = ExposedSymbols {
top_level_values: exposed_to_host,
exported_closure_types,
};

if let EntryPoint::Executable { platform_path, .. } = &loaded.entry_point {
let stub_lib = platform_path.with_file_name(target.stub_app_lib_file_name());
let stub_dll_symbols = exposed_symbols.stub_dll_symbols();
generate_dynamic_lib(target, &stub_dll_symbols, stub_lib.as_path());
(platform_path.into(), stub_lib, stub_dll_symbols)
} else {
unreachable!();
}
}

pub fn generate_stub_lib_from_loaded(
target: Target,
platform_main_roc: &Path,
Expand Down
Loading