diff --git a/compiler/src/config.rs b/compiler/src/config.rs index 4fecb693a..a2b0f0e8f 100644 --- a/compiler/src/config.rs +++ b/compiler/src/config.rs @@ -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"); diff --git a/docs/source/getting-started/cli.md b/docs/source/getting-started/cli.md index f94178044..05b8889ba 100644 --- a/docs/source/getting-started/cli.md +++ b/docs/source/getting-started/cli.md @@ -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`.