Closed Bug 956931 Opened 6 years ago Closed 6 years ago

ICU linker error doing 32-bit and universal builds (undefined symbol _posix_fcallocate)

Categories

(Firefox Build System :: General, defect)

x86
macOS
defect
Not set

Tracking

(Not tracked)

RESOLVED FIXED
mozilla29

People

(Reporter: smichaud, Assigned: smichaud)

References

Details

Attachments

(1 file, 1 obsolete file)

This bug only happens doing a cross-compile of ICU (as we do for 32-bit and universal FF builds, but not for 64-bit ones), while rebuilding config/icucross.mk.

It happens while checking whether we have a working C compiler (using the 10.7 SDK on OS X 10.8) or a working C++ compiler (using the 10.6 SDK on OS X 10.7)!  Oddly it doesn't happen with our official universal builds (not yet sure why).

1 warning generated.
Undefined symbols for architecture i386:
  "_posix_fallocate", referenced from:
      _main in conftest-uT9aTf.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
configure: failed program was:
#line 14998 "configure"
#include "confdefs.h"
#define _XOPEN_SOURCE 600
  #include <fcntl.h>
int main() {
posix_fallocate(0, 0, 0);
; return 0; }

I don't know why this test references posix_fallocate() -- that may in fact be the bug (or at least a symptom of it).

I'd bet this bug was caused by the patch for bug 915735.  If so this bug is probably related to bug bug 948876.
See Also: → 948876
Blocks: 915735
Hmm, note that bug 915735 did not change how we build ICU on Mac by default, unless if you have --enable-shared-js in your mozconfig.
> I'd bet this bug was caused by the patch for bug 915735.

Actually not by itself.  So I'll need to hg bisect.

I have a very plain-vanilla .mozconfig.

Once I've found the trigger I'll report back.
Actually the trigger is the patch for bug 937901:

http://hg.mozilla.org/mozilla-central/log?rev=d73e10e80b85

user:        Mike Shal <mshal@mozilla.com>
date:        Wed Dec 11 15:07:58 2013 -0500
summary:     Bug 937901 - Support OSX ICU cross-compiling; r=glandium

Which makes sense.  And which probably also means that bug 915735 and bug 948876 are completely unrelated.
Blocks: 937901
No longer blocks: 915735
See Also: 948876
> Oddly it doesn't happen with our official universal builds

Tomorrow I'll try to figure out why.
Can you post your mozconfig and some steps to reproduce? And just to clarify, this is using a 10.8 machine to build 10.7 binaries? Or what exactly is your host/target configuration?
I have two separate sets of steps to reproduce -- one for OS X 10.7 (building with the 10.6 SDK, for 10.6 and up) and one for OS X 10.8 (building with the 10.7 SDK, for 10.7 and up).  For convenience I'll only describe the steps for 32-bit builds (universal builds are more complex and take twice as long).

A) Building on OS X 10.7 with the 10.6 SDK

1) Install the XCode 4.6.2 commandline tools for Lion, dated April 2013
2) Copy the following to your .mozconfig:

   export CFLAGS="-g -gfull"
   export CXXFLAGS="-g -gfull"
   mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-firefox-32bit
   mk_add_options MOZ_MAKE_FLAGS=-j4
   mk_add_options AUTOCONF=autoconf213
   ac_add_options --disable-optimize
   ac_add_options --enable-tests
   ac_add_options --enable-cpp-rtti
   ac_add_options --enable-logrefcnt
   ac_add_options --disable-strip
   ac_add_options --disable-install-strip
   ac_add_options --with-macos-sdk=/Developer/SDKs/MacOSX10.6.sdk
   ac_add_options --enable-macos-target=10.6

   CC="clang -arch i386 -mmacosx-version-min=10.6"
   CXX="clang++ -arch i386 -mmacosx-version-min=10.6"
   ac_add_options --target=i386-apple-darwin10.0.0
   ac_add_options --enable-macos-target=10.6

   HOST_CC="clang"
   HOST_CXX="clang++"
   RANLIB=ranlib
   AR=ar
   AS=$CC
   LD=ld
   STRIP="strip -x -S"
   CROSS_COMPILE=1

3) Run 'make -f client.mk build'.

B) Building on OS X 10.8 with the 10.7 SDK

1) Install the XCode 4.6.2 commandline tools for MountainLion, dated April 2013
2) Copy the following to your .mozconfig:

   export CFLAGS="-g -gfull"
   export CXXFLAGS="-g -gfull"
   mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-firefox-32bit
   mk_add_options MOZ_MAKE_FLAGS=-j12
   mk_add_options AUTOCONF=autoconf213
   ac_add_options --disable-optimize
   ac_add_options --enable-tests
   ac_add_options --enable-cpp-rtti
   ac_add_options --enable-logrefcnt
   ac_add_options --disable-strip
   ac_add_options --disable-install-strip
   ac_add_options --with-macos-sdk=/Developer/SDKs/MacOSX10.7.sdk

   CC="clang -arch i386 -mmacosx-version-min=10.7"
   CXX="clang++ -arch i386 -mmacosx-version-min=10.7"
   ac_add_options --target=i386-apple-darwin11.0.0
   ac_add_options --enable-macos-target=10.7

   HOST_CC="clang"
   HOST_CXX="clang++"
   RANLIB=ranlib
   AR=ar
   AS=$CC
   LD=ld
   STRIP="strip -x -S"
   CROSS_COMPILE=1

3) Run 'make -f client.mk build'.
Attached patch Fix (obsolete) — Splinter Review
I've figured out what's going on here:

https://hg.mozilla.org/mozilla-central/annotate/948bfed4eb68/js/src/configure.in#l4370

This line and the next assume that "-g" is the only form taken by the gcc/clang parameter that specifies debugging options.  But that's not true -- there's also "-gdwarf", "-gfull", "-g0", "-g1" and many others.

   export CFLAGS="-g -gfull"
   export CXXFLAGS="-g -gfull"

Here's how my mozconfig files specify debugging options.  Take away the "-g" from "-gfull" and you have nonsense.

This patch makes ICU compile properly with my mozconfigs.  It also includes an unrelated, drive-by change to the misspelled $HOST_OPTIMZIE_FLAGS variable.
Assignee: nobody → smichaud
Attachment #8356779 - Flags: review?(mshal)
Strangely this patch makes my cross build (linux host -> OSX target) now fail with the same _posix_fallocate error. I'll play around with it a bit in my setup, but your patch looks promising.
Maybe it'd help to specify non-whitespace characters more fully, like this:

[^ \t\r\n\v\f]
It seems autoconf is eating the [] characters, so I had to add the changequote() lines:

            changequote(,)
            ICU_CFLAGS=`echo $ICU_CFLAGS | sed 's|-g[^ \t]*||g'`
            ICU_CXXFLAGS=`echo $ICU_CXXFLAGS | sed 's|-g[^ \t]*||g'`
            changequote([,])

Similar patterns exist elsewhere in configure.in. Does that work for you?
> Does that work for you?

Yes, it does!

I just finished a 32-bit build, and had no problems.
Comment on attachment 8356779 [details] [diff] [review]
Fix

r+ conditional on the two changequote() lines being added per #c11.
Attachment #8356779 - Flags: review?(mshal) → review+
Attached patch Fix rev1Splinter Review
I've now thought of something else that needs to be fixed:  We only need to get rid of -g[...] flags when cross-compiling for Darwin on a non-Darwin host.

This patch works for me.  Could you try it?
Attachment #8356779 - Attachment is obsolete: true
Attachment #8357199 - Flags: review?(mshal)
Comment on attachment 8357199 [details] [diff] [review]
Fix rev1

Works for me!
Attachment #8357199 - Flags: review?(mshal) → review+
https://hg.mozilla.org/mozilla-central/rev/6b05f2b6391d
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla29
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.