Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 387481 - sys-devel/binutils-apple-4.1: Can't build LTO (patch attached)
Summary: sys-devel/binutils-apple-4.1: Can't build LTO (patch attached)
Status: VERIFIED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Prefix Support (show other bugs)
Hardware: All OS X
: Normal minor
Assignee: Gentoo Prefix
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-18 00:13 UTC by Charles Davis
Modified: 2011-10-19 16:36 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch to makefile to fix bug (binutils-apple-4.1-lto.patch,919 bytes, patch)
2011-10-18 03:25 UTC, Charles Davis
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Charles Davis 2011-10-18 00:13:32 UTC
Assuming you managed to install LLVM and, for LLVM trunk, fix all the library references (which I did, but that's another story, for another bug), it should theoretically be possible to build the Darwin static linker with LTO support. Unfortunately, if you try this, the build fails with:

Undefined symbols for architecture i386:
  "lto::parse(unsigned char const*, unsigned long long, char const*, long, unsigned int, int, int, bool)", referenced from:
      _main in ObjectDump.o
ld: symbol(s) not found for architecture i386

while trying to link the ObjectDump program.

For some reason, ObjectDump's make rule does not list the LTO file support (ld/parsers/lto_file.o) as a dependency, even when LTO is enabled. Furthermore, both ObjectDump and ld64 do not link to -lLTO when LTO is enabled.

Attached is a patch that fixes this and allows binutils-apple to finish building with LTO enabled.

Reproducible: Always

Steps to Reproduce:
1. emerge llvm
2. fix library references in LLVM binaries/libraries (has to be done manually)
3. USE=lto emerge =sys-devel/binutils-apple-4.1
Actual Results:  
Build fails because of missing dependencies in Makefile.

Expected Results:  
Build should succeed and result in a linker that understands LLVM bitcode files.

Portage 2.2.01.19478-prefix (prefix/darwin/macos/10.6/x86, gcc-4.2.1, unavailable, 10.8.0 i386)
=================================================================
                        System Settings
=================================================================
System uname: Darwin-10.8.0-i386-32bit
Timestamp of tree: Mon, 17 Oct 2011 23:10:48 +0000
distcc 3.1-toolwhip.1 i386-apple-darwin10.0 [disabled]
ccache version 3.1.4 [disabled]
app-shells/bash:      4.2_p10
dev-lang/python:      2.7.2
dev-util/ccache:      3.1.4
dev-util/cmake:       2.8.5-r2
dev-util/pkgconfig:   0.25-r2
sys-devel/autoconf:   2.68
sys-devel/automake:   1.10.3, 1.11.1
sys-devel/gcc-config: 1.4.1-r00.2
sys-devel/libtool:    2.4-r01.1
sys-devel/make:       3.82
Repositories: gentoo_prefix
Installed sets: 
ACCEPT_KEYWORDS="~x86-macos"
ACCEPT_LICENSE="* -@EULA"
CBUILD="i686-apple-darwin10"
CFLAGS="-O2 -pipe -march=core2"
CHOST="i686-apple-darwin10"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/portage /etc/revdep-rebuild /etc/terminfo"
CXXFLAGS="-O2 -pipe -march=core2"
DISTDIR="/Users/chip/Gentoo/usr/portage/distfiles"
FEATURES="assume-digests binpkg-logs collision-protect distlocks ebuild-locks fixlafiles news nostrip parallel-fetch preserve-libs protect-owned sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS=""
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LDFLAGS="-Wl,-dead_strip_dylibs"
MAKEOPTS="-j4"
PKGDIR="/Users/chip/Gentoo/usr/portage/packages"
PORTAGE_CONFIGROOT="/Users/chip/Gentoo/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/Users/chip/Gentoo/var/tmp"
PORTDIR="/Users/chip/Gentoo/usr/portage"
PORTDIR_OVERLAY=""
SYNC="rsync://rsync.prefix.freens.org/gentoo-portage-prefix"
USE="X aqua bash-completion berkdb bzip2 cairo coreaudio cracklib crypt curl cxx dbus doc exceptions expat extensions fontconfig gdbm gmp gnutls gpg gzip iconv icu ipv6 jbig jpeg libssh2 lzma lzo mmx mmxext mng modules mysql ncurses nls objc objc++ opengl pch perl png prefix python qt3support readline ruby sasl sql sqlite3 sse sse2 ssl subversion tcl threads tiff tk truetype unicode vim-syntax x86-macos xinerama xml xpm xv zlib" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CAMERAS="ptp2" ELIBC="Darwin" GPSD_PROTOCOLS="garmin garmintxt gpsclock" INPUT_DEVICES="keyboard mouse" KERNEL="Darwin" PHP_TARGETS="php5-3" RUBY_TARGETS="ruby18" SANE_BACKENDS="apple" USERLAND="GNU"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LINGUAS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

=================================================================
                        Package Settings
=================================================================

sys-devel/binutils-apple-3.2.6 was built with the following:
USE="(prefix) -lto -test"
CFLAGS="-O2 -pipe -march=core2 -ULTO_SUPPORT"
CXXFLAGS="-O2 -pipe -march=core2 -ULTO_SUPPORT"


sys-devel/binutils-apple-4.1 was built with the following:
USE="(prefix) -lto -test"
CFLAGS="-O2 -pipe -march=core2 -ULTO_SUPPORT -DNDEBUG -I/Users/chip/Gentoo/var/tmp/portage/sys-devel/binutils-apple-4.1/work/libunwind/include"
CXXFLAGS="-O2 -pipe -march=core2 -ULTO_SUPPORT -DNDEBUG -I/Users/chip/Gentoo/var/tmp/portage/sys-devel/binutils-apple-4.1/work/libunwind/include"
Comment 1 Charles Davis 2011-10-18 03:25:08 UTC
Created attachment 290127 [details, diff]
Patch to makefile to fix bug
Comment 2 Fabian Groffen gentoo-dev 2011-10-18 07:03:20 UTC
Ah, nice.  The makefile is ours (Apple stuff comes with project builder files -- Xcode build these days), so this should be an easy fix, thanks for diving into it!
Comment 3 Fabian Groffen gentoo-dev 2011-10-18 16:44:36 UTC
I applied your patch with small changes.  Most notably no point in using two variables for the same value/problem (LD64LIBS/LTO_OBJ).

Thanks!
Comment 4 Charles Davis 2011-10-18 22:41:10 UTC
Uh, you seem to have broken linking the ld64 executable. In particular, you left out the main() function :). Did you remember to use the LD64LIBS variable?

Also, you can re-enable machocheck now, because it seems to build OK.
Comment 5 Fabian Groffen gentoo-dev 2011-10-19 06:45:46 UTC
Hmm, oops.  Ok, fixed (and verified this time).
Comment 6 Charles Davis 2011-10-19 16:36:17 UTC
Thanks!