Building perf with static linking

1,653 views
Skip to first unread message

Simon Que

unread,
May 8, 2013, 5:14:38 PM5/8/13
to chromium-os-dev
I'm trying to build perf with static linking, and running into some trouble.  My command is:

   LDFLAGS=-static emerge-link perf

The Makefile fails with this error:

  Makefile:479: *** No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel.  Stop.

Okay fine, I emerged libelf for BOARD=link.  I had to uninstall elfutils first because apparently they can't both be installed.

The perf ebuild file has an RDEPEND on elfutils.  I removed that line so that it wouldn't attempt to build elfutils.

Now I'm emerging perf again, with the static flag.  It fails with these errors:

util/symbol.c: In function 'elf_read_build_id':
util/symbol.c:1465:3: error: unknown type name 'GElf_Nhdr'
util/symbol.c:1466:26: error: request for member 'n_namesz' in something not a structure or union
util/symbol.c:1467:26: error: request for member 'n_descsz' in something not a structure or union
util/symbol.c:1473:11: error: request for member 'n_type' in something not a structure or union
util/symbol.c:1474:11: error: request for member 'n_namesz' in something not a structure or union
util/symbol.c: In function 'sysfs__read_build_id':
util/symbol.c:1530:3: error: unknown type name 'GElf_Nhdr'
util/symbol.c:1536:19: error: request for member 'n_namesz' in something not a structure or union
util/symbol.c:1537:19: error: request for member 'n_descsz' in something not a structure or union
util/symbol.c:1538:11: error: request for member 'n_type' in something not a structure or union
util/symbol.c:1539:11: error: request for member 'n_namesz' in something not a structure or union


Browsing online, I found

Seems like I'm not the only one who ran into this problem, and it doesn't seem to be resolved thee.

Simon

Mike Frysinger

unread,
May 8, 2013, 5:16:22 PM5/8/13
to Simon Que, chromium-os-dev
err, elfutils provides libelf. i think what you meant to do was:
USE=static-libs emerge-link elfutils
-mike
> --
> --
> Chromium OS Developers mailing list: chromiu...@chromium.org
> View archives, change email options, or unsubscribe:
> http://groups.google.com/a/chromium.org/group/chromium-os-dev?hl=en
>
>
>

Simon Que

unread,
May 8, 2013, 5:32:42 PM5/8/13
to Mike Frysinger, chromium-os-dev
Still getting that Makefile error during perf build, after emerging elfutils with the static-libs USE flag.

Sonny Rao

unread,
May 8, 2013, 5:32:43 PM5/8/13
to Simon Que, chromium-os-dev
So, if upstream doesn't do this correctly, we'll have to patch the
ChromiumOS kernel to handle it -- and ideally ping upstream again with
the patch

Mike Frysinger

unread,
May 8, 2013, 5:50:25 PM5/8/13
to Sonny Rao, Simon Que, chromium-os-dev
yes, upstream is broken (wrt static builds w/elfutils). simple fix:
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -117,7 +117,7 @@ ifndef PERF_DEBUG
endif

CFLAGS = -fno-omit-frame-pointer -ggdb3 -Wall -Wextra -std=gnu99
$(CFLAGS_WERROR) $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2
$(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
-EXTLIBS = -lpthread -lrt -lelf -lm
+EXTLIBS = -lelf -lpthread -lrt -lm
ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
-D_GNU_SOURCE
ALL_LDFLAGS = $(LDFLAGS)
STRIP ?= strip

when it comes to using libelf, i don't think we care. let someone
else waste time on that :).
-mike

Mike Frysinger

unread,
May 8, 2013, 5:58:33 PM5/8/13
to Sonny Rao, Simon Que, chromium-os-dev

Shravan Garlapati

unread,
Sep 10, 2013, 7:36:59 PM9/10/13
to chromiu...@chromium.org, Sonny Rao, Simon Que

I am facing with same errors. How did you guys fix this?

...................................................................................

Mike Frysinger

unread,
Sep 10, 2013, 7:58:33 PM9/10/13
to Shravan Garlapati, Simon Que, Sonny Rao, chromiu...@chromium.org

please look at the link you replied to.  it has already been merged into the upstream kernel too.  so maybe you just need to update your kernel version.
-mike

Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages