Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 237629 - dev-lang/ocaml cross-compile failure (calls gcc directly instead of CHOST-gcc)
Summary: dev-lang/ocaml cross-compile failure (calls gcc directly instead of CHOST-gcc)
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High minor (vote)
Assignee: Gentoo Team for the ML programming language family
: 243882 267324 (view as bug list)
Depends on:
Reported: 2008-09-14 12:53 UTC by Mieszko Ślusarczyk
Modified: 2014-12-01 16:37 UTC (History)
5 users (show)

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

ocaml-3.12.1.ebuild-multilib.patch (ocaml-3.12.1.ebuild-multilib.patch,964 bytes, patch)
2011-08-12 16:35 UTC, Mario Fetka (geos_one)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mieszko Ślusarczyk 2008-09-14 12:53:20 UTC
When I try to compile ocaml using distcc on x86 32bit machine it fails.
The second machine is x86_64.

gcc -c -I../byterun -DCAML_NAME_SPACE -DNATIVE_CODE -DTARGET_i386 -DSYS_linux_elf  -pg -O -DPROFILING -march=pentium2 -O2 -pipe -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT gc_ctrl.c
distcc[23235] ERROR: compile /var/tmp/ccache/gc_ctrl.tmp.mieszko-serwer.23231.i on failed
gc_ctrl.c:1: error: CPU you selected does not support x86-64 instruction set
gc_ctrl.c:1: error: CPU you selected does not support x86-64 instruction set
make[1]: *** [gc_ctrl.p.o] Error 1
make[1]: Leaving directory `/var/tmp/portage/dev-lang/ocaml-3.10.2/work/ocaml-3.10.2/asmrun'

Reproducible: Always
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2008-09-14 21:08:54 UTC
Please post your `emerge --info' too and inspect your /usr/lib/distcc/bin for the obvious problems with issuing a bare `gcc' where a arch-vendor-kernel-libc-gcc should have been used. After that, we can probably work out a way to make dev-lang/ocaml ebuilds respect CHOST better.
Comment 2 Mieszko Ślusarczyk 2008-09-14 21:18:37 UTC
I've set my distcc host using this guide: (usng crossdev)

This is my emerge --info:

Portage 2.2_rc8 (default/linux/x86/2008.0, gcc-4.3.1, glibc-2.8_p20080602-r0, 2.6.27-rc5-zen2 i686)
System uname: Linux-2.6.27-rc5-zen2-i686-Pentium_II_-Deschutes-with-glibc2.0
Timestamp of tree: Sun, 14 Sep 2008 17:18:01 +0000
distcc 2.18.3 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disabled]
ccache version 2.4 [enabled]
app-shells/bash:     3.2_p39
dev-lang/python:     2.5.2-r7
dev-python/pycrypto: 2.0.1-r6
dev-util/ccache:     2.4-r7
sys-apps/baselayout: 2.0.0
sys-apps/openrc:     0.2.5
sys-devel/autoconf:  2.62-r1
sys-devel/automake:  1.5, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.1-r1
sys-devel/binutils:  2.18-r3
sys-devel/gcc-config: 1.4.0-r4
sys-devel/libtool:   2.2.4
virtual/os-headers:  2.6.26
CFLAGS="-march=pentium2 -O2 -mmmx -pipe -fomit-frame-pointer"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/terminfo /etc/udev/rules.d"
CXXFLAGS="-march=pentium2 -O2 -mmmx -pipe -fomit-frame-pointer"
FEATURES="ccache distlocks parallel-fetch preserve-libs sandbox sfperms strict unmerge-orphans userfetch"
LINGUAS="pl en"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTDIR_OVERLAY="/usr/portage/local/layman/thousand-parsec /usr/portage/local/layman/gentoo-de /usr/portage/local/layman/jyujin /usr/portage/local/layman/kde-testing /usr/portage/local/layman/rox /usr/portage/local/layman/gnash-cvs /usr/portage/local/layman/php-4 /usr/portage/local/layman/roslin /usr/portage/local/layman/ruby /usr/portage/local/layman/pd-overlay /usr/portage/local/layman/openoffice-geki /usr/portage/local/layman/desktop-effects /usr/portage/local/layman/wrobel /usr/portage/local/layman/enlightenment /usr/portage/local/layman/drizzt-overlay /usr/portage/local/layman/nouveau /usr/portage/local/layman/mpd /usr/portage/local/layman/perl-experimental /usr/portage/local/layman/zugaina /usr/portage/local/layman/dberkholz /usr/portage/local/layman/wschlich-testing /usr/portage/local/layman/voip /usr/portage/local/layman/d /usr/portage/local/layman/finnish /usr/portage/local/layman/lxde /usr/portage/local/layman/secondlife /usr/portage/local/layman/chtekk-syscp /usr/portage/local/layman/xwing /usr/portage/local/layman/soor-overlay /usr/portage/local/layman/x11 /usr/portage/local/layman/jokey /usr/portage/local/layman/falco /usr/portage/local/layman/java-overlay /usr/portage/local/layman/dirtyepic /usr/portage/local/layman/kde /usr/portage/local/layman/hanno-xgl /usr/portage/local/layman/sipx /usr/portage/local/layman/vmware /usr/portage/local/layman/halcy0n /usr/portage/local/layman/je_fro /usr/portage/local/layman/cell /usr/portage/local/layman/trauma /usr/portage/local/layman/kolab /usr/portage/local/layman/verlihub /usr/portage/local/layman/vdr-devel /usr/portage/local/layman/powerpc /usr/portage/local/layman/graaff /usr/portage/local/layman/gentoo-taiwan /usr/portage/local/layman/wolf31o2 /usr/portage/local/layman/java-gcj-overlay /usr/portage/local/layman/toolchain /usr/portage/local/layman/gnome /usr/portage/local/layman/kdesvn-portage /usr/portage/local/layman/lapis /usr/portage/local/layman/chtekk-apps /usr/portage/local/layman/games /usr/portage/local/layman/gentopia /usr/portage/local/layman/xfce /usr/portage/local/layman/pda /usr/portage/local/layman/masterdriverz /usr/portage/local/layman/berkano /usr/portage/local/layman/akoya /usr/portage/local/layman/marineam-xen /usr/portage/local/layman/hollow /usr/portage/local/layman/armagetron /usr/portage/local/layman/flameeyes-overlay /usr/portage/local/layman/openrc /usr/portage/local/layman/s3d /usr/portage/local/layman/n4g-experimental /usr/portage/local/layman/ltsp /usr/portage/local/layman/n4g /usr/portage/local/layman/initng /usr/portage/local/layman/dertobi123 /usr/portage/local/layman/emacs /usr/portage/local/layman/arcon /usr/portage/local/layman/voyageur /usr/portage/local/layman/php-experimental /usr/portage/local/layman/dev-zero /usr/portage/local/layman/deathwing00 /usr/portage/local/layman/hawking /usr/portage/local/layman/vdr-1.5 /usr/portage/local/layman/mozilla /usr/portage/local/layman/gcc-porting /usr/portage/local/layman/efika /usr/portage/local/layman/devnull /usr/portage/local/layman/trapni /usr/portage/local/layman/interactive-fiction /usr/portage/local/layman/webapps-experimental /usr/portage/local/layman/science /usr/portage/local/layman/rbu /usr/portage/local/layman/eclipse /usr/portage/local/layman/pro-audio /usr/portage/local/layman/seemant /usr/portage/local/layman/vdr-experimental /usr/portage/local/layman/pythonhead /usr/portage/local/layman/genstef /usr/portage/local/layman/kerberos /usr/portage/local/layman/wschlich /usr/portage/local/layman/gentoojp /usr/portage/local/layman/oss-overlay /usr/portage/local/layman/plan9 /usr/portage/local/layman/freevo /usr/portage/local/layman/php-testing /usr/portage/local/layman/iwlwifi /usr/portage/local/layman/postgresql-experimental /usr/portage/local/layman/vdr-testing /usr/portage/local/layman/bangert /usr/portage/local/layman/suka /usr/portage/local/layman/luke-jr /usr/portage/local/layman/nx /usr/portage/local/layman/sunrise /usr/portage/local/layman/xemacs /usr/portage/local/layman/philantrop /usr/portage/local/layman/pioto-overlay /usr/portage/local/layman/xen /usr/portage/local/layman/postgresql-testing /usr/portage/local/layman/darkside /usr/portage/local/layman/gentoo-china /usr/portage/local/layman/ikelos /usr/portage/local/layman/vps /usr/portage/local/layman/aross /usr/portage/local/layman/lu_zero /usr/portage/local/layman/kvm /usr/portage/local/layman/mysql-testing /usr/portage/local/layman/liquidx /usr/portage/local/layman/lila-theme /usr/portage/local/layman/zen-overlay /usr/portage/local/layman/gnustep /usr/portage/local/layman/welp /usr/portage/local/layman/swegener /home/mieszko/overlay/mieszko /home/mieszko/overlay/kaxero/foo-sharp /home/mieszko/overlay/kaxero/gentoo-misc /home/mieszko/overlay/kaxero/gnome"
USE="a52 aac aalib acl acpi adns afs alsa ao apache2 apm atm audiofile avahi bash-completion bcmath berkdb bluetooth bzip2 cddb cdparanoia cdr clamav cli cracklib crypt css ctype cups curl curlwrappers cvs cxx dbus dri dts dv dvb dvd dvdread encode expat fam fastcgi flac fortran ftp gdbm ggi gmp gnutls gphoto2 gpm gsl gstreamer hal hddtemp iconv ieee1394 imagemagick ipod ipv6 isdnlog krb4 ladspa lame ldap libcaca libsamplerate libwww lighttpd lm_sensors lzo mad memlimit midi mime mmx mono mp3 mpeg mplayer mudflap musepack musicbrainz mysql nas ncurses nls nntp nptl nptlonly ogg openmp oss pam pcre perl php pppd profile pulseaudio python quicktme raw readline reflection rss ruby samba scanner session slang slp snmp speex spl sqlite ssl subversion suid symlink sysfs szip taglib tcpd threads timidity unicode usb v4l v4l2 vcd vhosts vorbis wavpack wifi win32codecs x264 x86 xine xml xmlrpc xorg xvid zeroconf zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" 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 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" ELIBC="glibc" INPUT_DEVICES="keyboard" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="pl en" USERLAND="GNU" VIDEO_CARDS="fbdev glint i810 mach64 mga neomagic nv r128 radeon savage sis tdfx trident vesa vga via vmware voodoo"
Comment 3 Jeroen Roovers (RETIRED) gentoo-dev 2008-09-15 14:16:48 UTC
It seems like even with myconf="--host ${CHOST}", the ocaml build system ignores CHOST. :) I can't readily confirm this, but I do see that on a HPPA system, it doesn't call hppa2.0-unknown-linux-gnu-gcc, but simply gcc.
Comment 4 Alexis Ballier gentoo-dev 2008-09-15 14:24:48 UTC
well, first of all, to avoid future problems due to poor build systems like this one you'll need to setup the symlinks hacks as explained on

then yes, ocaml calls gcc directly; i am not sure how to fix this, as there are two things to keep in mind:
- you may want to cross compile it and have ocamlopt produce code for you native arch
- you may want ocamlopt to produce code for a different arch
- ocamlopt also calls gcc itself to link the binaries

ocaml itself is a compiler, so things aren't that easy as forcing it to call $CHOST-gcc; and of course patches are welcome
Comment 5 Alexis Ballier gentoo-dev 2008-10-24 23:08:43 UTC
*** Bug 243882 has been marked as a duplicate of this bug. ***
Comment 6 Alexis Ballier gentoo-dev 2009-04-28 20:44:39 UTC
*** Bug 267324 has been marked as a duplicate of this bug. ***
Comment 7 Mario Fetka (geos_one) 2010-12-14 22:19:12 UTC
there already exists a croscompile patch

Comment 8 Mario Fetka (geos_one) 2011-08-12 16:35:40 UTC
Created attachment 283055 [details, diff]

this patch makes it possible to compile it with multilib portage
Comment 9 Alexis Ballier gentoo-dev 2012-11-01 16:16:25 UTC
(In reply to comment #8)
> Created attachment 283055 [details, diff] [details, diff]
> ocaml-3.12.1.ebuild-multilib.patch
> this patch makes it possible to compile it with multilib portage

-	RAW_LDFLAGS="$(raw-ldflags)" ./configure -prefix /usr \
+	RAW_LDFLAGS="${STD_LDFLAGS/-m32/${EMUL_LDFLAGS}}" ./configure -prefix /usr \

as already said, multilib portage people should make raw-ldflags work well and translate -m32 to -m elf_i386 based on CHOST instead of adding hacks to ebuilds; this should also make the first hunk of your patch not needed.

-		-cc "$(tc-getCC)" \
-		-as "$(tc-getAS)" \
-		-aspp "$(tc-getCC) -c" \
+		-cc "$(tc-getCC) ${CFLAGS}" \
+		-as "$(tc-getAS) ${ASFLAGS}" \
+		-aspp "$(tc-getCC) ${CFLAGS} -c" \

ocaml should respect cflags without this, could you please point me where they are ignored ?
Comment 10 Alexis Ballier gentoo-dev 2014-12-01 16:37:02 UTC
ocaml ebuild now should properly pass CBUILD/CHOST but upstream use tryrun constructs that make this not sufficient; closing as upstream