Bug 271052 - lang/gcc12 fails on arm64: tar: Pathname can't be converted from UTF-8 to current locale.
Summary: lang/gcc12 fails on arm64: tar: Pathname can't be converted from UTF-8 to cur...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: arm64 Any
: --- Affects Only Me
Assignee: Lorenzo Salvadore
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-24 20:22 UTC by Vidar Karlsen
Modified: 2023-08-18 00:39 UTC (History)
6 users (show)

See Also:
salvadore: maintainer-feedback+


Attachments
Full poudriere error log (11.01 KB, text/plain)
2023-04-24 20:22 UTC, Vidar Karlsen
no flags Details
workaround (1.43 KB, patch)
2023-05-09 16:08 UTC, Lorenzo Salvadore
no flags Details | Diff
workaround v2 (1.37 KB, patch)
2023-05-09 21:00 UTC, Lorenzo Salvadore
no flags Details | Diff
workaround v3 (1.55 KB, patch)
2023-05-10 10:26 UTC, Lorenzo Salvadore
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vidar Karlsen 2023-04-24 20:22:50 UTC
Created attachment 241711 [details]
Full poudriere error log

Cross-building lang/gcc12 for arm64.aarch64 with poudriere qemu-user-static fails during extract phase:

# poudriere jail -l
132arm64        13.2-RELEASE     arm64.aarch64 http   2023-04-14 23:37:20 /usr/local/poudriere/jails/132arm64

# poudriere testport -j 132arm64 -b latest -p usrports -i lang/gcc12
[...]
Making GCC 12.2.0 for aarch64-portbld-freebsd13.2 [c,c++,objc,fortran,jit]
===>  License GPLv3 GPLv3RLE accepted by the user
===>   gcc12-12.2.0_6 depends on file: /usr/local/sbin/pkg - found
===> Fetching all distfiles required by gcc12-12.2.0_6 for building
===>  Extracting for gcc12-12.2.0_6
=> SHA256 Checksum OK for gcc-12.2.0.tar.xz.
tar: Pathname can't be converted from UTF-8 to current locale.
tar: Pathname can't be converted from UTF-8 to current locale.
tar: Error exit delayed from previous errors.
===>  Failed to extract "/portdistfiles//gcc-12.2.0.tar.xz".
*** Error code 1
Comment 1 Lorenzo Salvadore freebsd_committer freebsd_triage 2023-04-25 10:09:15 UTC
I have started to study the issue. Can you please provide some more details about the locale in the jail: is it the default? which one is it? Thanks.
Comment 2 Vidar Karlsen 2023-04-25 10:19:48 UTC
(In reply to Lorenzo Salvadore from comment #1)
It's default, I haven't changed any locale settings.

nobody@132arm64-usrports:/usr/ports/lang/gcc12 % locale
LANG=C.UTF-8
LC_CTYPE="C.UTF-8"
LC_COLLATE="C.UTF-8"
LC_TIME="C.UTF-8"
LC_NUMERIC="C.UTF-8"
LC_MONETARY="C.UTF-8"
LC_MESSAGES="C.UTF-8"
LC_ALL=
Comment 3 Lorenzo Salvadore freebsd_committer freebsd_triage 2023-04-27 22:52:29 UTC
I can reproduce the bug. Still studying the issue.

Interesting note: trying to extract the distfile within the jail with tar -xvf works. So I guess the issue must be searched either in the specifc command run in the port extraction phase or in the environment set by poudriere.
Comment 4 Lorenzo Salvadore freebsd_committer freebsd_triage 2023-05-09 08:15:04 UTC
I am still working on it. Here are a few more observations:

- lang/gcc12 appears to be the only problematic port: testing lang/gcc12-devel and lang/gcc13 works;

- I am preparing the update of lang/gcc12 to 12.3.0. I have already tested it on aarch64 and unfortunately the bug is still present.

- The locale used by poudriere at build time is different than the one used in the poudriere jail. It is

LANG=C
LC_CTYPE="C"                                                                                                                                                                                   
LC_COLLATE="C"                                   
LC_TIME="C"
LC_NUMERIC="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_ALL=C

  I have obtained it by patching the `do-extract:` target in bsd.port.mk. The same locale are used with lang/gcc12 on amd64 and with lang/gcc13 on aarch64 without issues.

- The problematic files are

gcc-12.3.0/gcc/testsuite/go.test/test/fixedbugs/issue27836.dir/\303\204foo.go
gcc-12.3.0/gcc/testsuite/go.test/test/fixedbugs/issue27836.dir/\303\204main.go

also known as

gcc-12.3.0/gcc/testsuite/go.test/test/fixedbugs/issue27836.dir/Äfoo.go
gcc-12.3.0/gcc/testsuite/go.test/test/fixedbugs/issue27836.dir/Ämain.go

  The files are present in lang/gcc13 too.

Since the problem is version specific, GCC 13 is already out and my hope is to have it become GCC_DEFAULT soon enough, I might fix this port with a workaround rather than a real bug fix. However, I still have no workaround ready.

CCing a few more people:

- bapt, who might help with poudriere internals;
- mm, who is the main maintainer of libarchive in the src repository and thus might understand better what is going on here;
- gerald, past maintainer of the GCC ports, he might remember similar issues in the past.
Comment 5 Gerald Pfeifer freebsd_committer freebsd_triage 2023-05-09 08:48:45 UTC
(In reply to Lorenzo Salvadore from comment #4)
> - gerald, past maintainer of the GCC ports, he might remember
>   similar issues in the past.

This is a first for me. I definitely do not recall this in the FreeBSD
context, nor from my following the upstream mailing lists.
Comment 6 Mikael Urankar freebsd_committer freebsd_triage 2023-05-09 14:16:44 UTC
IIRC it's a bug in qemu-user
Comment 7 Lorenzo Salvadore freebsd_committer freebsd_triage 2023-05-09 16:08:29 UTC
Created attachment 242079 [details]
workaround

Here is a patch that seems to work around the problem: it switches to GNU tar for aarch64.

I am still testing it. Feel free to also give it a try.
Comment 8 Gerald Pfeifer freebsd_committer freebsd_triage 2023-05-09 16:30:54 UTC
Did this very patch work for you? As far as I can tell ${ARCH} is only
defined after .include <bsd.port.pre.mk>.
Comment 9 Lorenzo Salvadore freebsd_committer freebsd_triage 2023-05-09 16:36:35 UTC
(In reply to Gerald Pfeifer from comment #8)

I am still testing it, but for now I can confirm that extraction is successfully using gtar in an aarch64 13.2-RELEASE poudriere jail. I also confirm that this is exactly the patch I am testing.
Comment 10 Gerald Pfeifer freebsd_committer freebsd_triage 2023-05-09 17:02:10 UTC
Interesting! I am getting this on ref12-amd64:

  ~/ports/lang/gcc12> uname -or
  FreeBSD 12.4-STABLE

  ~/ports/lang/gcc12> make -V EXTRACT_CMD
  make: "/home/gerald/ports/lang/gcc12/Makefile" line 30: Malformed conditional (${ARCH} == aarch64)
  make: Fatal errors encountered -- cannot continue
Comment 11 Lorenzo Salvadore freebsd_committer freebsd_triage 2023-05-09 21:00:23 UTC
Created attachment 242083 [details]
workaround v2

I tested ref12-amd64 with the same result as you got Gerald.

I have changed the patch so that ARCH is tested after importing bsd.port.pre.mk. I do not know why it was working fine on my machine and why it is not on the reference machine.

By the way, the reference machine acts weirdly for me: when I login I get the following message:

Cannot read termcap database;
using dumb terminal settings.

And vim cannot be used properly: I am unable to move the cursor using arrows. It works however using hjkl. Is it expected or should I contact clusteradm@?
Comment 12 Gerald Pfeifer freebsd_committer freebsd_triage 2023-05-09 21:18:30 UTC
(In reply to Lorenzo Salvadore from comment #11)
> I tested ref12-amd64 with the same result as you got Gerald.
>
> I have changed the patch so that ARCH is tested after importing 
> bsd.port.pre.mk. I do not know why it was working fine on my machine
> and why it is not on the reference machine.

I am guessing you have defined ARCH in the environment somewhere?

> By the way, the reference machine acts weirdly for me: when I login
> I get the following message:
>
> Cannot read termcap database;
> using dumb terminal settings.

The shell I am invoking SSH from (i.e., on my local system) has
TERM=xterm-256color which then works fine on the cluster machine.
Comment 13 Mikael Urankar freebsd_committer freebsd_triage 2023-05-10 06:55:56 UTC
See also: bug #246670
Comment 14 Lorenzo Salvadore freebsd_committer freebsd_triage 2023-05-10 10:26:15 UTC
Created attachment 242096 [details]
workaround v3

Thanks Mikael, I have improved the patch with the information that I have found in the bug report you provided, so that it now does not add an extra dependency on gtar any more.
Still testing the new version, but for now it seems to work.

Thanks Gerald, your suggestion about TERM is useful: setting it to xterm-256color works.
Comment 15 Lorenzo Salvadore freebsd_committer freebsd_triage 2023-05-10 15:21:31 UTC
All my tests passed with the proposed patch. I am now testing the same patch for lang/gcc11.

Vidar: Can you please confirm the patch works for you too? Thanks.
Comment 16 Lorenzo Salvadore freebsd_committer freebsd_triage 2023-05-10 21:17:38 UTC
All tests passed successfully for lang/gcc11 too.
Comment 17 Vidar Karlsen 2023-05-12 07:48:28 UTC
(In reply to Lorenzo Salvadore from comment #15)

> Vidar: Can you please confirm the patch works for you too? Thanks.

The workaround v3 patch works for me on 13.2 arm64.aarch64 (qemu).
Comment 18 commit-hook freebsd_committer freebsd_triage 2023-05-12 15:41:07 UTC
A commit in branch main references this bug:

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

commit 5b4cadb23cbc2db23d7e2a40c16abd3e862fcf62
Author:     Lorenzo Salvadore <salvadore@FreeBSD.org>
AuthorDate: 2023-05-09 15:26:00 +0000
Commit:     Lorenzo Salvadore <salvadore@FreeBSD.org>
CommitDate: 2023-05-12 15:39:47 +0000

    lang/gcc12: Work around aarch64 extraction bug

    Extraction fails with poudriere on aarch64 with the following error:

    => SHA256 Checksum OK for gcc-12.2.0.tar.xz.
    tar: Pathname can't be converted from UTF-8 to current locale.
    tar: Pathname can't be converted from UTF-8 to current locale.
    tar: Error exit delayed from previous errors.

    Enforcing use of bsdtar works around the issue. The issue is specific to
    lang/gcc11 and lang/gcc12: no other GCC port is affected.

    See also bug https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=246670.

    PR:             271052
    Reported by:    Vidar Karlsen <vidar@karlsen.tech>
    Reviewed by:    gerald, mikael

 lang/gcc12/Makefile | 9 +++++++++
 1 file changed, 9 insertions(+)
Comment 19 commit-hook freebsd_committer freebsd_triage 2023-05-12 15:41:08 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=22530ba28be79b947e617dc1288896bfc3c6f6ef

commit 22530ba28be79b947e617dc1288896bfc3c6f6ef
Author:     Lorenzo Salvadore <salvadore@FreeBSD.org>
AuthorDate: 2023-05-10 15:11:05 +0000
Commit:     Lorenzo Salvadore <salvadore@FreeBSD.org>
CommitDate: 2023-05-12 15:39:38 +0000

    lang/gcc11: Work around aarch64 extraction bug

    Extraction fails with poudriere on aarch64 with the following error:

    => SHA256 Checksum OK for gcc-11.3.0.tar.xz.
    tar: Pathname can't be converted from UTF-8 to current locale.
    tar: Pathname can't be converted from UTF-8 to current locale.
    tar: Error exit delayed from previous errors.

    Enforcing use of bsdtar works around the issue. The issue is specific to
    lang/gcc11 and lang/gcc12: no other GCC port is affected.

    See also bug https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=246670.

    PR:             271052
    Reported by:    Vidar Karlsen <vidar@karlsen.tech>
    Reviewed by:    gerald, mikael

 lang/gcc11/Makefile | 9 +++++++++
 1 file changed, 9 insertions(+)
Comment 20 Lorenzo Salvadore freebsd_committer freebsd_triage 2023-05-12 15:43:03 UTC
Fixed, thanks to everyone.
Comment 21 commit-hook freebsd_committer freebsd_triage 2023-05-12 17:16:28 UTC
A commit in branch 2023Q2 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=2cbbd136ada7dc9207759b698830d5a9d58b22df

commit 2cbbd136ada7dc9207759b698830d5a9d58b22df
Author:     Lorenzo Salvadore <salvadore@FreeBSD.org>
AuthorDate: 2023-05-10 15:11:05 +0000
Commit:     Lorenzo Salvadore <salvadore@FreeBSD.org>
CommitDate: 2023-05-12 17:15:17 +0000

    lang/gcc11: Work around aarch64 extraction bug

    Extraction fails with poudriere on aarch64 with the following error:

    => SHA256 Checksum OK for gcc-11.3.0.tar.xz.
    tar: Pathname can't be converted from UTF-8 to current locale.
    tar: Pathname can't be converted from UTF-8 to current locale.
    tar: Error exit delayed from previous errors.

    Enforcing use of bsdtar works around the issue. The issue is specific to
    lang/gcc11 and lang/gcc12: no other GCC port is affected.

    See also bug https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=246670.

    PR:             271052
    Reported by:    Vidar Karlsen <vidar@karlsen.tech>
    Reviewed by:    gerald, mikael

    (cherry picked from commit 22530ba28be79b947e617dc1288896bfc3c6f6ef)

 lang/gcc11/Makefile | 9 +++++++++
 1 file changed, 9 insertions(+)
Comment 22 commit-hook freebsd_committer freebsd_triage 2023-05-12 17:16:29 UTC
A commit in branch 2023Q2 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=8e62ef36512902760104fb756edba5cb0704bb0f

commit 8e62ef36512902760104fb756edba5cb0704bb0f
Author:     Lorenzo Salvadore <salvadore@FreeBSD.org>
AuthorDate: 2023-05-09 15:26:00 +0000
Commit:     Lorenzo Salvadore <salvadore@FreeBSD.org>
CommitDate: 2023-05-12 17:15:18 +0000

    lang/gcc12: Work around aarch64 extraction bug

    Extraction fails with poudriere on aarch64 with the following error:

    => SHA256 Checksum OK for gcc-12.2.0.tar.xz.
    tar: Pathname can't be converted from UTF-8 to current locale.
    tar: Pathname can't be converted from UTF-8 to current locale.
    tar: Error exit delayed from previous errors.

    Enforcing use of bsdtar works around the issue. The issue is specific to
    lang/gcc11 and lang/gcc12: no other GCC port is affected.

    See also bug https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=246670.

    PR:             271052
    Reported by:    Vidar Karlsen <vidar@karlsen.tech>
    Reviewed by:    gerald, mikael

    (cherry picked from commit 5b4cadb23cbc2db23d7e2a40c16abd3e862fcf62)

 lang/gcc12/Makefile | 9 +++++++++
 1 file changed, 9 insertions(+)
Comment 23 Jose Luis Duran freebsd_committer freebsd_triage 2023-08-18 00:39:24 UTC
I had to apply the same fix to:

- devel/aarch64-none-elf-gcc

So poudriere could cross-compile.