Bug 271076 - games/punchy: fix build on armv7 (preliminary)
Summary: games/punchy: fix build on armv7 (preliminary)
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: arm Any
: --- Affects Only Me
Assignee: Jan Beich
URL: https://pkg-status.freebsd.org/ampere...
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-26 10:00 UTC by Robert Clausecker
Modified: 2023-05-01 10:15 UTC (History)
1 user (show)

See Also:
jbeich: maintainer-feedback+
jbeich: merge-quarterly+


Attachments
games/punchy: fix build on armv7 (14.56 KB, patch)
2023-04-26 10:00 UTC, Robert Clausecker
fuz: maintainer-approval? (jbeich)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Clausecker freebsd_committer freebsd_triage 2023-04-26 10:00:41 UTC
Created attachment 241755 [details]
games/punchy: fix build on armv7

The attached patch fixes build issues on armv7.  Unfortunately, the build then crashes during the final link with what looks like an address space exhaustion.
Comment 1 commit-hook freebsd_committer freebsd_triage 2023-04-28 20:45:53 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=5acf5a02777bd9c6cce20980859c4316b267f6f2

commit 5acf5a02777bd9c6cce20980859c4316b267f6f2
Author:     Robert Clausecker <fuz@FreeBSD.org>
AuthorDate: 2023-04-26 00:36:30 +0000
Commit:     Jan Beich <jbeich@FreeBSD.org>
CommitDate: 2023-04-28 20:44:40 +0000

    games/punchy: unbreak build on armv7

    Fix files/patch-v8 to compile on armv7 by refactoring it to use
    ELF auxilliary vectors in the CPU detection code and by adding
    some missing includes.

    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:137:20: warning: implicit declaration of function 'READ_SPECIALREG' is invalid in C99 [-Wimplicit-function-declaration]
        id_aa64isar0 = READ_SPECIALREG(id_aa64isar0_el1);
                       ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:137:36: error: use of undeclared identifier 'id_aa64isar0_el1'; did you mean 'id_aa64isar0'?
        id_aa64isar0 = READ_SPECIALREG(id_aa64isar0_el1);
                                       ^~~~~~~~~~~~~~~~
                                       id_aa64isar0
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:136:14: note: 'id_aa64isar0' declared here
        uint64_t id_aa64isar0;
                 ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:138:9: warning: implicit declaration of function 'ID_AA64ISAR0_AES' is invalid in C99 [-Wimplicit-function-declaration]
        if (ID_AA64ISAR0_AES_VAL(id_aa64isar0) == ID_AA64ISAR0_AES_PMULL)
            ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:42:30: note: expanded from macro 'ID_AA64ISAR0_AES_VAL'
     #define ID_AA64ISAR0_AES_VAL ID_AA64ISAR0_AES
                                  ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:138:47: error: use of undeclared identifier 'ID_AA64ISAR0_AES_PMULL'; did you mean 'ID_AA64ISAR0_AES'?
        if (ID_AA64ISAR0_AES_VAL(id_aa64isar0) == ID_AA64ISAR0_AES_PMULL)
                                                  ^~~~~~~~~~~~~~~~~~~~~~
                                                  ID_AA64ISAR0_AES
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:138:9: note: 'ID_AA64ISAR0_AES' declared here
        if (ID_AA64ISAR0_AES_VAL(id_aa64isar0) == ID_AA64ISAR0_AES_PMULL)
            ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:42:30: note: expanded from macro 'ID_AA64ISAR0_AES_VAL'
     #define ID_AA64ISAR0_AES_VAL ID_AA64ISAR0_AES
                                  ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:140:9: warning: implicit declaration of function 'ID_AA64ISAR0_CRC32' is invalid in C99 [-Wimplicit-function-declaration]
        if (ID_AA64ISAR0_CRC32_VAL(id_aa64isar0) == ID_AA64ISAR0_CRC32_BASE)
            ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:45:32: note: expanded from macro 'ID_AA64ISAR0_CRC32_VAL'
     #define ID_AA64ISAR0_CRC32_VAL ID_AA64ISAR0_CRC32
                                    ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:140:49: error: use of undeclared identifier 'ID_AA64ISAR0_CRC32_BASE'; did you mean 'ID_AA64ISAR0_CRC32'?
        if (ID_AA64ISAR0_CRC32_VAL(id_aa64isar0) == ID_AA64ISAR0_CRC32_BASE)
                                                    ^~~~~~~~~~~~~~~~~~~~~~~
                                                    ID_AA64ISAR0_CRC32
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:140:9: note: 'ID_AA64ISAR0_CRC32' declared here
        if (ID_AA64ISAR0_CRC32_VAL(id_aa64isar0) == ID_AA64ISAR0_CRC32_BASE)
            ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:45:32: note: expanded from macro 'ID_AA64ISAR0_CRC32_VAL'
     #define ID_AA64ISAR0_CRC32_VAL ID_AA64ISAR0_CRC32
                                    ^

    PR:             271076
    Reported by:    pkg-fallout

 games/punchy/Makefile       |  2 +-
 games/punchy/files/patch-v8 | 50 +++++++++++++++++++++++++++++----------------
 2 files changed, 33 insertions(+), 19 deletions(-)
Comment 2 commit-hook freebsd_committer freebsd_triage 2023-04-28 20:46:54 UTC
A commit in branch 2023Q2 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=16a3aa5cb9e71ff22cbdceb0bd56b1d61e4d53ce

commit 16a3aa5cb9e71ff22cbdceb0bd56b1d61e4d53ce
Author:     Robert Clausecker <fuz@FreeBSD.org>
AuthorDate: 2023-04-26 00:36:30 +0000
Commit:     Jan Beich <jbeich@FreeBSD.org>
CommitDate: 2023-04-28 20:45:57 +0000

    games/punchy: unbreak build on armv7

    Fix files/patch-v8 to compile on armv7 by refactoring it to use
    ELF auxilliary vectors in the CPU detection code and by adding
    some missing includes.

    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:137:20: warning: implicit declaration of function 'READ_SPECIALREG' is invalid in C99 [-Wimplicit-function-declaration]
        id_aa64isar0 = READ_SPECIALREG(id_aa64isar0_el1);
                       ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:137:36: error: use of undeclared identifier 'id_aa64isar0_el1'; did you mean 'id_aa64isar0'?
        id_aa64isar0 = READ_SPECIALREG(id_aa64isar0_el1);
                                       ^~~~~~~~~~~~~~~~
                                       id_aa64isar0
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:136:14: note: 'id_aa64isar0' declared here
        uint64_t id_aa64isar0;
                 ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:138:9: warning: implicit declaration of function 'ID_AA64ISAR0_AES' is invalid in C99 [-Wimplicit-function-declaration]
        if (ID_AA64ISAR0_AES_VAL(id_aa64isar0) == ID_AA64ISAR0_AES_PMULL)
            ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:42:30: note: expanded from macro 'ID_AA64ISAR0_AES_VAL'
     #define ID_AA64ISAR0_AES_VAL ID_AA64ISAR0_AES
                                  ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:138:47: error: use of undeclared identifier 'ID_AA64ISAR0_AES_PMULL'; did you mean 'ID_AA64ISAR0_AES'?
        if (ID_AA64ISAR0_AES_VAL(id_aa64isar0) == ID_AA64ISAR0_AES_PMULL)
                                                  ^~~~~~~~~~~~~~~~~~~~~~
                                                  ID_AA64ISAR0_AES
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:138:9: note: 'ID_AA64ISAR0_AES' declared here
        if (ID_AA64ISAR0_AES_VAL(id_aa64isar0) == ID_AA64ISAR0_AES_PMULL)
            ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:42:30: note: expanded from macro 'ID_AA64ISAR0_AES_VAL'
     #define ID_AA64ISAR0_AES_VAL ID_AA64ISAR0_AES
                                  ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:140:9: warning: implicit declaration of function 'ID_AA64ISAR0_CRC32' is invalid in C99 [-Wimplicit-function-declaration]
        if (ID_AA64ISAR0_CRC32_VAL(id_aa64isar0) == ID_AA64ISAR0_CRC32_BASE)
            ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:45:32: note: expanded from macro 'ID_AA64ISAR0_CRC32_VAL'
     #define ID_AA64ISAR0_CRC32_VAL ID_AA64ISAR0_CRC32
                                    ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:140:49: error: use of undeclared identifier 'ID_AA64ISAR0_CRC32_BASE'; did you mean 'ID_AA64ISAR0_CRC32'?
        if (ID_AA64ISAR0_CRC32_VAL(id_aa64isar0) == ID_AA64ISAR0_CRC32_BASE)
                                                    ^~~~~~~~~~~~~~~~~~~~~~~
                                                    ID_AA64ISAR0_CRC32
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:140:9: note: 'ID_AA64ISAR0_CRC32' declared here
        if (ID_AA64ISAR0_CRC32_VAL(id_aa64isar0) == ID_AA64ISAR0_CRC32_BASE)
            ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:45:32: note: expanded from macro 'ID_AA64ISAR0_CRC32_VAL'
     #define ID_AA64ISAR0_CRC32_VAL ID_AA64ISAR0_CRC32
                                    ^

    PR:             271076
    Reported by:    pkg-fallout

    (cherry picked from commit 5acf5a02777bd9c6cce20980859c4316b267f6f2)

 games/punchy/Makefile       |  2 +-
 games/punchy/files/patch-v8 | 50 +++++++++++++++++++++++++++++----------------
 2 files changed, 33 insertions(+), 19 deletions(-)
Comment 3 Jan Beich freebsd_committer freebsd_triage 2023-04-28 20:53:28 UTC
Thanks. Landed without "make makepatch" noise.

> Unfortunately, the build then crashes during the final link with what looks like an address space exhaustion.

How much RAM do you have? The package cluster builds armv7 on aarch64, so a single process can use up to 4GB but many processes can use up to 1TB together. Assuming LPAE on armv7 works similar to PAE on i386.

Cargo.toml has lto=true, so try adding CARGO_ENV+=CARGO_PROFILE_RELEASE_LTO="false" to Makefile.local
Comment 4 Robert Clausecker freebsd_committer freebsd_triage 2023-04-28 22:21:25 UTC
(In reply to Jan Beich from comment #3)

I have 32 GB of memory.  I specifically say "address space exhaustion" to indicate that the rustc process probably ran out of virtual address space.  This is not fixable by adding more memory.
Comment 5 Robert Clausecker freebsd_committer freebsd_triage 2023-05-01 10:15:20 UTC
Building with CARGO_ENV+=CARGO_PROFILE_RELEASE_LTO="false" did not help.  I'm beginning to suspect that this may really be a bug in the rust toolchain.