Bug 30779 - gprofng: fails to build with musl-1.2.4 (gprofng/src/Data_window.h:56:3: error: 'off64_t' does not name a type; did you mean 'off_t'?)
Summary: gprofng: fails to build with musl-1.2.4 (gprofng/src/Data_window.h:56:3: erro...
Status: ASSIGNED
Alias: None
Product: binutils
Classification: Unclassified
Component: gprofng (show other bugs)
Version: 2.41
: P3 normal
Target Milestone: ---
Assignee: Vladimir Mezentsev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-08-18 07:34 UTC by Sam James
Modified: 2024-01-13 06:29 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sam James 2023-08-18 07:34:35 UTC
```
/bin/sh ../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I../../.././gprofng/src -I..  -U_ASM -DLOCALEDIR=\"/usr/local/share/locale\" -DSYSCONFDIR=\"/usr/local/etc\" -DLIBDIR=\"/usr/local/lib\" -I.. -I../../.././gprofng/src -I../../.././gprofng/src/../common -I../../.././gprofng/src/../../include -I../../.././gprofng/src/../../opcodes -I../../bfd -I../../.././gprofng/src/../../bfd -I../../.././gprofng/../zlib  -Wall -pthread -Wno-switch -g -O2     -MT Dbe.lo -MD -MP -MF $depbase.Tpo -c -o Dbe.lo ../../.././gprofng/src/Dbe.cc &&\
mv -f $depbase.Tpo $depbase.Plo
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I../../.././gprofng/src -I.. -U_ASM -DLOCALEDIR=\"/usr/local/share/locale\" -DSYSCONFDIR=\"/usr/local/etc\" -DLIBDIR=\"/usr/local/lib\" -I.. -I../../.././gprofng/src -I../../.././gprofng/src/../common -I../../.././gprofng/src/../../include -I../../.././gprofng/src/../../opcodes -I../../bfd -I../../.././gprofng/src/../../bfd -I../../.././gprofng/../zlib -Wall -pthread -Wno-switch -g -O2 -MT Dbe.lo -MD -MP -MF .deps/Dbe.Tpo -c ../../.././gprofng/src/Dbe.cc -o Dbe.o
In file included from ../../.././gprofng/src/Exp_Layout.h:31,
                 from ../../.././gprofng/src/MemorySpace.h:28,
                 from ../../.././gprofng/src/DbeSession.h:50,
                 from ../../.././gprofng/src/Dbe.cc:31:
../../.././gprofng/src/Data_window.h:56:3: error: 'off64_t' does not name a type; did you mean 'off_t'?
   56 |   off64_t get_fsize ()          { return fsize; }
      |   ^~~~~~~
      |   off_t
In file included from ../../.././gprofng/src/LoadObject.h:27,
                 from ../../.././gprofng/src/Dbe.cc:40:
../../.././gprofng/src/Stabs.h:90:28: error: 'ino64_t' has not been declared
   90 |     Stab_status read_stabs(ino64_t srcInode, Module *module, Vector<ComC*> *comComs, bool readDwarf = false);
      |                            ^~~~~~~
../../.././gprofng/src/LoadObject.h:194:3: error: 'ino64_t' does not name a type; did you mean 'int64_t'?
  194 |   ino64_t inode;                // inode number of segment file
      |   ^~~~~~~
      |   int64_t
In file included from ../../.././gprofng/src/Function.h:28,
                 from ../../.././gprofng/src/Dbe.cc:45:
../../.././gprofng/src/SourceFile.h:59:3: error: 'ino64_t' does not name a type; did you mean 'int64_t'?
   59 |   ino64_t
      |   ^~~~~~~
      |   int64_t
../../.././gprofng/src/SourceFile.h:106:3: error: 'ino64_t' does not name a type; did you mean 'int64_t'?
  106 |   ino64_t srcInode;         // Inode number of source file
      |   ^~~~~~~
      |   int64_t
make[5]: *** [Makefile:844: Dbe.lo] Error 1
```

This is with musl-1.2.4 which drops the LFS types because it always has native LFS.

I suggest using -D_FILE_OFFSET_BITS=64 via AC_SYS_LARGEFILE and then always using ino_t and friends, which will work on glibc too.
Comment 1 Sam James 2023-08-18 07:41:10 UTC
Downstream report: https://bugs.gentoo.org/912284
Full build log (xz compressed): https://bugs.gentoo.org/attachment.cgi?id=867845

I can give more information if needed.
Comment 2 Vladimir Mezentsev 2023-08-25 04:29:40 UTC
I don't use musl.
But I fixed couple bugs in gprofng to build on x86_64-pc-linux-musl.
I did on my machine:
% wget https://distfiles.adelielinux.org/adelie/1.0/iso/rc2/adelie-rootfs-mini-x86_64-1.0-rc2.txz
% sudo tar xf adelie-rootfs-mini-x86_64-1.0-rc2.txz
% sudo systemd-nspawn --directory=. -M mez_musl
Spawning container mez_musl on /data2/vmezents/musl.
Press ^] three times within 1s to kill container.
-sh: 0: can't access tty; job control turned off

/sbin/apk add bash && bash
/sbin/apk add build-tools m4 bison flex gmp-dev texinfo
cd /home && mkdir bld && cd bld
../binutils-gdb.git/configure --prefix=`pwd`/INSTALL  --enable-multilib --disable-gdb --disable-gdbsupport --disable-gdbserver

I fixed the compiler errors (open64, fgetpo64 and fsetpos64 are redefined) in gprofng.
But I don't see errors about off64_t or ino64_t.

I use this system:
% uname -a
Linux mez_musl 5.4.17-2136.318.7.1.el8uek.x86_64 #2 SMP Thu Apr 13 17:33:39 PDT 2023 x86_64 GNU/Linux


My questions are:
 How can I simply use/download musl-1.2.4 ?
 Is the bug on Arm or on Intel ?
Comment 3 Sam James 2023-08-25 14:48:33 UTC
(In reply to Vladimir Mezentsev from comment #2)
> [...]
> My questions are:
>  How can I simply use/download musl-1.2.4 ?

Unfortunately, I think Adelie is a bit out of date in general at the moment. Alpine edge should have the latest musl or I can give you some instructions for a Gentoo docker container.

The bug will need >=musl-1.2.4 to reproduce.

>  Is the bug on Arm or on Intel ?

Intel in this case (amd64/x86_64).
Comment 4 John Doe 2023-09-25 13:18:29 UTC
> I fixed the compiler errors (open64, fgetpo64 and fsetpos64 are redefined) in gprofng.

This seems to be missing in git upstream.
Comment 5 Sam James 2023-12-16 04:17:51 UTC
Any update here? It'd be great to have this one fixed before 2.42.
Comment 6 Vladimir Mezentsev 2023-12-21 06:40:16 UTC
We have the other bugs against gprofng-musl:
29477 Build failure on musl: collector_module.h:78:13: error: duplicate member ‘pwrite’ 
29593 error: '__u64' undeclared (first use in this function) for aarch64-linux-musl host
30893 gprofng uses syscall + perf_event (hwcdrv) and ptrace (gpcollect) without any check and doc
 
I can fix build issues.
But I cannot fix the run time problem before 2.42.
The known problem is getcontext() is absent in libc on musl.
Comment 7 Kurt Goebel 2023-12-21 14:32:15 UTC
    Thank you for responding to musl issues!

     Good to let them know where we are

     I'm sure they appreciate your explanation

     Kurt


On 12/21/23 1:40 AM, vladimir.mezentsev at oracle dot com wrote:
> https://urldefense.com/v3/__https://sourceware.org/bugzilla/show_bug.cgi?id=30779__;!!ACWV5N9M2RV99hQ!K8Dln1WWQeCCQikDkZ4YfU3DWeoY0g0f8XOHvICdnaL4Erz9EFGO4EsNZ38vVxWPFab06Fkq_ttgUVKBML7aVmprh5kKeByd$
>
> Vladimir Mezentsev <vladimir.mezentsev at oracle dot com> changed:
>
>             What    |Removed                     |Added
> ----------------------------------------------------------------------------
>               Status|NEW                         |ASSIGNED
>             See Also|                            |https://urldefense.com/v3/__https://sourceware.org/bugz__;!!ACWV5N9M2RV99hQ!K8Dln1WWQeCCQikDkZ4YfU3DWeoY0g0f8XOHvICdnaL4Erz9EFGO4EsNZ38vVxWPFab06Fkq_ttgUVKBML7aVmprhwhmEanT$
>                     |                            |illa/show_bug.cgi?id=29477,
>                     |                            |https://urldefense.com/v3/__https://sourceware.org/bugz__;!!ACWV5N9M2RV99hQ!K8Dln1WWQeCCQikDkZ4YfU3DWeoY0g0f8XOHvICdnaL4Erz9EFGO4EsNZ38vVxWPFab06Fkq_ttgUVKBML7aVmprhwhmEanT$
>                     |                            |illa/show_bug.cgi?id=29593
>
> --- Comment #6 from Vladimir Mezentsev <vladimir.mezentsev at oracle dot com> ---
> We have the other bugs against gprofng-musl:
> 29477 Build failure on musl: collector_module.h:78:13: error: duplicate member
> ‘pwrite’
> 29593 error: '__u64' undeclared (first use in this function) for
> aarch64-linux-musl host
> 30893 gprofng uses syscall + perf_event (hwcdrv) and ptrace (gpcollect) without
> any check and doc
>
> I can fix build issues.
> But I cannot fix the run time problem before 2.42.
> The known problem is getcontext() is absent in libc on musl.
>
Comment 8 Sourceware Commits 2023-12-23 05:27:14 UTC
The master branch has been updated by Vladimir Mezentsev <vmezents@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=576d2c97d8de26d1ab5a2058e8ba4ffd00b8096d

commit 576d2c97d8de26d1ab5a2058e8ba4ffd00b8096d
Author: Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
Date:   Thu Dec 21 21:33:58 2023 -0800

    gprofng: fix build problems on linux-musl
    
    ino64_t, off64_t, fpos64_t, stat64, __u64 are not defined on linux-musl.
    Fixed by declaring these types for linux-musl.
    
    2023-12-21  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>
    
            PR gprofng/30779
            PR gprofng/29593
            * common/gp-defs.h: Define ino64_t, off64_t, fpos64_t for linux-musl.
            * libcollector/unwind.c: Define __u64 for linux-musl.
            * src/util.h: Define dbe_stat_t.
            * src/ClassFile.cc: Use dbe_stat_t instead of "struct stat64".
            * src/Dbe.cc: Likewise.
            * src/DbeFile.cc: Likewise.
            * src/DbeFile.h: Likewise.
            * src/DbeSession.cc: Likewise.
            * src/Experiment.cc: Likewise.
            * src/checks.cc: Likewise.
            * src/util.cc: Likewise.
Comment 9 Vladimir Mezentsev 2024-01-11 03:27:59 UTC
Has the build problem been fixed in your environment?
Comment 10 Adam Baxter 2024-01-13 06:29:29 UTC
Hi Vladimir - I also hit this, I can confirm this patch fixes *this specific compilation error* but I cannot confirm that everything builds correctly as I am hitting other environment-specific problems.