hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 772ec67db3961cb8c06512e9602a53a2f1d87447
parent e63fc5f72ec73a07af4fe2b67e541cc06768f593
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Fri,  3 Feb 2023 18:40:50 +0100

cmd/hare: Stick to POSIX ar(1) flags to avoid requiring ARFLAGS

This also makes ARFLAGS consistent with CFLAGS as being designed for extra user flags.

Tested with GNU Binutils ar(1) and LLVM ar(1).

Signed-off-by: Haelwenn (lanodan) Monnier <contact@hacktivis.me>

Diffstat:
Mcmd/hare/schedule.ha | 14++++----------
1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/cmd/hare/schedule.ha b/cmd/hare/schedule.ha @@ -166,19 +166,13 @@ fn sched_ar(plan: *plan, output: str, depend: *task...) *task = { status = status::SCHEDULED, output = output, depend = alloc(depend...), - cmd = getcmd(&ar_tool), + cmd = getcmd(&ar_tool, "-c", output), module = void, }); - // If you specify flags in `$ARFLAGS' or a different archiver in `$AR', - // this assumes that you will pass the correct flags for creating an - // archive, and will not pass the default `-csr', since `ar' is picky - // about the order flags are given. - if (len(task.cmd) == 1 && task.cmd[0] == plan.target.ar_cmd) { - append(task.cmd, "-csr"); - }; - - append(task.cmd, output); + // POSIX specifies `ar -r [-cuv] <archive> <file>` + // Add -r here so it is always before any ARFLAGS + insert(task.cmd[1], "-r"); for (let i = 0z; i < len(depend); i += 1) { assert(strings::hassuffix(depend[i].output, ".o"));