Skip to content

Commit

Permalink
Scope build files for non-native targets
Browse files Browse the repository at this point in the history
This ensures we don't end up using the wrong data (e.g. object file
caches) when compiling for different targets.

Changelog: changed
  • Loading branch information
yorickpeterse committed Jan 7, 2024
1 parent 4ca8d56 commit b733f01
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 8 additions & 4 deletions compiler/src/config.rs
Expand Up @@ -58,10 +58,14 @@ pub(crate) struct BuildDirectories {

impl BuildDirectories {
pub(crate) fn new(config: &Config) -> BuildDirectories {
let build = config
.opt
.directory_name()
.map_or(config.build.clone(), |p| config.build.join(p));
let root = if config.target.is_native() {
config.build.clone()
} else {
config.build.join(config.target.to_string())
};

let build =
config.opt.directory_name().map(|p| root.join(p)).unwrap_or(root);

let objects = build.join("objects");
let llvm_ir = build.join("llvm");
Expand Down
6 changes: 6 additions & 0 deletions docs/source/getting-started/cli.md
Expand Up @@ -54,4 +54,10 @@ You can specify an alternative output path using the `-o` option:
inko build -o /tmp/hello hello.inko
```

When compiling for the host/native target, build output is placed in `./build`
directly, but when building for a different architecture the output is scoped to
a directory named after that architecture. For example, when compiling for
arm64-linux-gnu on an amd64-linux-gnu host, build files are placed in
`./build/arm64-linux-gnu`.

For more information, run `inko --help`.

0 comments on commit b733f01

Please sign in to comment.