Bug 239669 - devel/valgrind fails to build after r348628
Summary: devel/valgrind fails to build after r348628
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Ed Maste
URL:
Keywords: regression
Depends on:
Blocks: 245997
  Show dependency treegraph
 
Reported: 2019-08-06 05:29 UTC by Yuichiro NAITO
Modified: 2021-04-11 01:28 UTC (History)
12 users (show)

See Also:
pjfloyd: maintainer-feedback?


Attachments
Fix build error (601 bytes, patch)
2020-04-19 13:34 UTC, Paul Floyd
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yuichiro NAITO 2019-08-06 05:29:19 UTC
Since r348628, FreeBSD head fails to build devel/valgrind as follows.
I believe this is not a port problem.

```
cc -DHAVE_CONFIG_H -I. -I..  -I.. -I../include -I../VEX/pub -I../VEX/pub -DVGA_x
86=1 -DVGO_freebsd=1 -DVGP_x86_freebsd=1 -DVGPV_x86_freebsd_vanilla=1 -I../coreg
rind -DVG_LIBDIR="\"/usr/local/lib/valgrind"\" -DVG_PLATFORM="\"x86-freebsd\""
-B/usr/lib32 -m32 -O2 -g -Wall -Wmissing-prototypes -Wshadow -Wpointer-arith -Ws
trict-prototypes -Wmissing-declarations -Wno-format-zero-length -Wno-tautologica
l-compare -fno-strict-aliasing -fno-builtin -fomit-frame-pointer  -Wno-long-long
 -O2 -pipe -march=skylake  -fstack-protector-strong -fno-strict-aliasing  -Wno-t
autological-compare -Wno-cast-align -Wno-self-assign -fno-stack-protector -MT m_
debuginfo/libcoregrind_x86_freebsd_a-readelf.o -MD -MP -MF m_debuginfo/.deps/lib
coregrind_x86_freebsd_a-readelf.Tpo -c -o m_debuginfo/libcoregrind_x86_freebsd_a
-readelf.o `test -f 'm_debuginfo/readelf.c' || echo './'`m_debuginfo/readelf.c
In file included from m_debuginfo/readelf.c:35:
In file included from ./pub_core_vki.h:44:
In file included from ../include/pub_tool_vki.h:54:
../include/vki/vki-freebsd.h:1958:1: warning: typedef requires a name
      [-Wmissing-declarations]
typedef struct vki_i386_get_xfpustate {
^~~~~~~
../include/vki/vki-freebsd.h:1963:1: warning: typedef requires a name
      [-Wmissing-declarations]
typedef struct vki_amd64_get_xfpustate {
^~~~~~~
m_debuginfo/readelf.c:1094:54: error: use of undeclared identifier
      'ELF_NOTE_GNU'
               if (ML_(img_strcmp_c)(img, name_ioff, ELF_NOTE_GNU) == 0
                                                     ^
m_debuginfo/readelf.c:1134:54: error: use of undeclared identifier
      'ELF_NOTE_GNU'
               if (ML_(img_strcmp_c)(img, name_ioff, ELF_NOTE_GNU) == 0
                                                     ^
```

r348628 commit added

``` #define        NT_GNU_BUILD_ID         3 ```

in sys/elf_common.h.

In m_debuginfo/readelf.c of valgrind source,

```
#  ifdef NT_GNU_BUILD_ID
   if (is_elf_object_file_by_DiImage(img, rel_ok)) {
(snip)
               if (ML_(img_strcmp_c)(img, name_ioff, ELF_NOTE_GNU) == 0
                   && note.n_type == NT_GNU_BUILD_ID) {

```

ELF_NOTE_GNU is referenced if NT_GNU_BUILD_ID is defined,
but it is not defined in sys/elf_common.h.

I've tried to add

``` #define ELF_NOTE_GNU            "GNU" ```

in sys/elf_common.h. It works for me.

Please consider to add the definition.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2019-08-06 09:20:34 UTC
Assign to committer of r348628.
Comment 2 Yuichiro NAITO 2019-08-30 01:39:52 UTC
I opened new differential on https://reviews.freebsd.org/D21472.
Please check and see it.
Comment 3 commit-hook freebsd_committer freebsd_triage 2019-09-20 09:05:38 UTC
A commit references this bug:

Author: emaste
Date: Fri Sep 20 09:04:52 UTC 2019
New revision: 352551
URL: https://svnweb.freebsd.org/changeset/base/352551

Log:
  elf_common: add ELF note names

  r348628 added a definition of NT_GNU_BUILD_ID.  Some software (Valgrind)
  also expects a #define for the note name (ELF_NOTE_GNU) in the case that
  NT_GNU_BUILD_ID is defined.

  PR:		239669
  Reported by:	Yuichiro NAITO
  Sponsored by:	The FreeBSD Foundation
  Event:		EuroBSDCon FreeBSD DevSummit 2019

Changes:
  head/sys/sys/elf_common.h
Comment 4 commit-hook freebsd_committer freebsd_triage 2019-09-26 16:39:43 UTC
A commit references this bug:

Author: emaste
Date: Thu Sep 26 16:39:33 UTC 2019
New revision: 352760
URL: https://svnweb.freebsd.org/changeset/base/352760

Log:
  MFC r352551: elf_common: add ELF note names

  r348628 added a definition of NT_GNU_BUILD_ID.  Some software (Valgrind)
  also expects a #define for the note name (ELF_NOTE_GNU) in the case that
  NT_GNU_BUILD_ID is defined.

  PR:		239669
  Sponsored by:	The FreeBSD Foundation

Changes:
_U  stable/12/
  stable/12/sys/sys/elf_common.h
Comment 5 Florian Walpen 2019-10-14 15:05:17 UTC
FYI, this one bites me on 12.1-RC1 - are these changes supposed to land in 12.1-RELEASE, or is it too late?
Comment 6 Patrick McMunn 2020-01-05 22:06:41 UTC
I encountered this error on 12.1-RELEASE-p1, so it definitely affects the release.
Comment 7 russo 2020-02-22 05:10:11 UTC
I just encountered this on my 11.3-STABLE system, after the valgrind port got updated yesterday.  Apparently 11.3 got the NT_GNU_BUILD_ID in sys/elf_common.h, too, but I never detected this problem because I had valgrind installed before I updated from 11.2 to 11.3, and the port hadn't needed to be recompiled until today.
Comment 8 Dirk Meyer freebsd_committer freebsd_triage 2020-02-23 06:00:07 UTC
workaround on 12.1-RELEASE-p2

cat /usr/ports/devel/valgrind/Makefile.local

CFLAGS+=        -DELF_NOTE_GNU=\\\"GNU\\\"
Comment 9 Matthias Andree freebsd_committer freebsd_triage 2020-04-08 08:27:51 UTC
This still affects 12.1-RELEASE-p2 builds in poudriere.
Comment 10 Paul Floyd 2020-04-19 13:34:25 UTC
Created attachment 213563 [details]
Fix build error

This should sort out the build error, and in the future should ELF_NOTE_GNU become defined again then it will do nothing.
Comment 11 Sean Champ 2020-04-28 09:59:05 UTC
In a contributed diff, I've added the update recommended by Paul Floyd to the patch file for vki-freebsd.h under the devel/valgrind port. The patch for the patch is incorporated into a diff/changeset for devel/valgrind, sysutils/dtc, emulator/qemu and emulators/qemu-devel submitted to FreeBSD bugzilla, this morning

available:

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=245997
Comment 12 Ulrich Spörlein freebsd_committer freebsd_triage 2020-09-11 14:28:37 UTC
This patch is actually obsolete, yes? Both devel/valgrind and devel/valgrind-devel build for me on 12.1-STABLE r364374

(though devel/valgrind-devel has been much advanced from the "stable" port)
Comment 13 Paul Floyd 2020-09-11 19:01:32 UTC
The patch is certainly not needed for devel/valgrind-devel.

I haven't tried compiling the old devel/valgrind code for a while. I'll check and update soon.
Comment 14 Paul Floyd 2020-09-12 19:27:50 UTC
I still get the same build failure for devel/valgrind with 12.1-RELEASE-p9.
Comment 15 Paul Floyd 2021-04-10 16:37:57 UTC
(In reply to Paul Floyd from comment #14)
This item can now be closed as we've now switched to an updated Valgrind codebase.