Skip to content

stack picks up wrong ar executable #6912

@arrowd

Description

@arrowd

On FreeBSD we always have the /usr/bin/ar executable which is a llvm-ar in disguise.

On my system I also have /usr/local/bin/ar executable that comes from the GNU binutils package. My PATH is set up in such a way that the base ar is preferred:

which ar
/usr/bin/ar

However, running stack --system-ghc build on my project results in

base-compat                  > [ 57 of 130] Compiling Data.Ratio.Compat
bsb-http-chunked             > /usr/local/bin/ar: invalid option -- L
bsb-http-chunked             > Usage: /usr/local/bin/ar [emulation options] [-]{dmpqrstx}[abcDfilMNoOPsSTuvV] [--plugin <name>] [member-name] [count] archive-file file...

The problem here is that GHC calls ar believing it supports the -L flag, which is true for /usr/bin/ar. But somehow the GNU version gets invoked instead.

Now, in /usr/local/lib/ghc-9.10.3/lib/settings I have

,("ar command", "ar")
,("ar flags", "qcls")
,("ar supports at file", "YES")
,("ar supports -L", "YES")

If I change it to ("ar command", "/usr/bin/ar") the problem goes away.

Stack version

stack --version
Version 3.9.1 x86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions