Opened 2 years ago

Closed 2 years ago

#64794 closed defect (fixed)

Cannot install ghc on arm

Reported by: essandess (Steve Smith) Owned by: essandess (Steve Smith)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: mascguy (Christopher Nielsen)
Port: ghc alex

Description

The latest version of ghc supports native arm compilation, but installing it with MacPorts throws this error:

--->  Computing dependencies for ghc
Error: Cannot install ghc for the arch 'arm64' because
Error: its dependency alex only supports the arch 'x86_64'.
Error: Follow https://guide.macports.org/#project.tickets if you believe there
is a bug.

Change History (15)

comment:1 Changed 2 years ago by essandess (Steve Smith)

The dependency alex is installed from MacPorts and runs on the M1:

file `which alex`
/opt/local/bin/alex: Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|PIE>
alex --version
Alex version 3.2.6, (c) 2003 Chris Dornan and Simon Marlow

comment:2 Changed 2 years ago by jmroot (Joshua Root)

Port: alex added

This is because alex, like every port that includes the haskell_stack portgroup, sets supported_archs x86_64. If alex's architecture doesn't matter to ghc, use depends_skip_archcheck. Or if alex only installs an executable, it could set installs_libs no.

comment:3 in reply to:  2 Changed 2 years ago by essandess (Steve Smith)

Replying to jmroot:

This is because alex, like every port that includes the haskell_stack portgroup, sets supported_archs x86_64. If alex's architecture doesn't matter to ghc, use depends_skip_archcheck. Or if alex only installs an executable, it could set installs_libs no.

I added installs_libs no to the haskell_stack portgroup, uninstalled and reinstalled alex, but still encounter the error on arm:

--->  Computing dependencies for ghc
Error: Cannot install ghc for the arch 'arm64' because
Error: its dependency alex only supports the arch 'x86_64'.
Error: Follow https://guide.macports.org/#project.tickets if you believe there
is a bug.

comment:4 in reply to:  2 Changed 2 years ago by essandess (Steve Smith)

Replying to jmroot:

This is because alex, like every port that includes the haskell_stack portgroup, sets supported_archs x86_64. If alex's architecture doesn't matter to ghc, use depends_skip_archcheck. Or if alex only installs an executable, it could set installs_libs no.

I added depends_skip_archcheck to the ghc Portfile, but still encounter this error on arm:

--->  Computing dependencies for ghc
Error: Cannot install ghc for the arch 'arm64' because
Error: its dependency alex only supports the arch 'x86_64'.
Error: Follow https://guide.macports.org/#project.tickets if you believe there
is a bug.

BTW, I've been explicitly adding ui_msg statements to ensure that my edits are invoked, e.g.

    # build depends upon x86_64 binary alex
    platform arm  {
        ui_msg "Port '${name}' on '${os.arch}'."
        depends_skip_archcheck
    }

comment:5 Changed 2 years ago by essandess (Steve Smith)

I've also tried (based upon https://github.com/macports/macports-base/blob/master/src/macports1.0/macports.tcl)

        depends_skip_archcheck-append \
                    alex
        depends_skip_archcheck-append \
                    port:alex

All result in the same architecture error.

comment:6 Changed 2 years ago by mascguy (Christopher Nielsen)

Cc: mascguy added

comment:7 Changed 2 years ago by mascguy (Christopher Nielsen)

Steve, does stack, alex, etc, now support ARM? If so, I can update the haskell_stack portgroup.

comment:8 in reply to:  7 ; Changed 2 years ago by essandess (Steve Smith)

Replying to mascguy:

Steve, does stack, alex, etc, now support ARM? If so, I can update the haskell_stack portgroup.

All stack builds are x86_64 binaries that run on M1. Please see https://github.com/macports/macports-ports/pull/13503 (and https://github.com/macports/macports-ports/pull/13505).

comment:9 in reply to:  8 Changed 2 years ago by mascguy (Christopher Nielsen)

Replying to essandess:

All stack builds are x86_64 binaries that run on M1. Please see https://github.com/macports/macports-ports/pull/13503 (and https://github.com/macports/macports-ports/pull/13505).

Ah, now I understand the problem. This is a challenging issue, as we don't want supported_archs to include ARM, if Intel binaries are being installed. (Though I also understand your point of view, per your PR comments.)

comment:10 Changed 2 years ago by jmroot (Joshua Root)

I added installs_libs no to the haskell_stack portgroup, uninstalled and reinstalled alex,

Adding it to the portgroup is certainly wrong; many of the ports using it install native libs AIUI. Also installs_libs is not stored in the registry, so reinstalling will not make any difference. Did you run portindex after making the change?

I added depends_skip_archcheck to the ghc Portfile, but still encounter this error on arm:

depends_skip_archcheck-append alex is right. It doesn't seem possible that you could still get exactly the same error given how the code works: https://github.com/macports/macports-base/blob/v2.7.2/src/macports1.0/macports.tcl#L3503-L3581

As you can see, an arch mismatch is only reported if $check_archs is true, and that is set to false if either the dependency sets installs_libs no or the dependency's name is in the current port's depends_skip_archcheck.

comment:11 Changed 2 years ago by kencu (Ken)

If you have to re-run portindex for these arch skipping changes to be recognized, I did not know that either...

Oh, the wasted hours because of such things :>

comment:12 in reply to:  10 Changed 2 years ago by essandess (Steve Smith)

Thanks. I missed the different error message with another stack-based dependency.

I've posted a draft PR at https://github.com/macports/macports-ports/pull/14234

It's a draft because there's some other build issue with the compiler not finding a necessary #include.

Replying to jmroot:

I added installs_libs no to the haskell_stack portgroup, uninstalled and reinstalled alex,

Adding it to the portgroup is certainly wrong; many of the ports using it install native libs AIUI. Also installs_libs is not stored in the registry, so reinstalling will not make any difference. Did you run portindex after making the change?

I added depends_skip_archcheck to the ghc Portfile, but still encounter this error on arm:

depends_skip_archcheck-append alex is right. It doesn't seem possible that you could still get exactly the same error given how the code works: https://github.com/macports/macports-base/blob/v2.7.2/src/macports1.0/macports.tcl#L3503-L3581

As you can see, an arch mismatch is only reported if $check_archs is true, and that is set to false if either the dependency sets installs_libs no or the dependency's name is in the current port's depends_skip_archcheck.

comment:13 Changed 2 years ago by essandess (Steve Smith)

I'll try the same approach on some of the other stack+arm related tickets.

What should the fix be when we're using stack on arm to build an x86_64 binary, but there's an arm dependency that MacPorts chokes on? See, e.g. https://trac.macports.org/ticket/63944:

sudo port destroot adblock2privoxy
Error: Cannot install adblock2privoxy for the arch 'x86_64' because
Error: its dependency sf-pwgen is only installed for the arch 'arm64'
Error: and does not have a universal variant.
Error: Unable to execute port: architecture mismatch

I tried depends_skip_archcheck-append sf-pwgen but still get this error.

comment:14 in reply to:  11 Changed 2 years ago by jmroot (Joshua Root)

Replying to kencu:

If you have to re-run portindex for these arch skipping changes to be recognized, I did not know that either...

Not having an up-to-date PortIndex will cause any number of issues. That's why it gets updated along with every sync.

comment:15 Changed 2 years ago by essandess (Steve Smith)

Owner: set to essandess
Resolution: fixed
Status: newclosed

In 777d81406cb9a7c261e921618c4ea39feba74389/macports-ports (master):

ghc: Add depends_skip_archcheck for platform arm, Fix prebuilt issues

Note: See TracTickets for help on using tickets.