Currently the build system of FFADO tries to detect the user space type (32bit/64bit) by examining /bin/mount, but this causes issues when compiling the source from a chroot (when /bin/mount well may be built for x86_64, or not even available, but the library should be 32bit). This has happened, see for example [1]. Thus I have written a patch that adds a "DETECT_USERSPACE" variable to the SConstruct script. The default (to detect userspace) is preserved, but having a flag allows disabling the detection and disable appending machine flags (-m32,-m64).
In Gentoo, where I am a maintainer, this patch is required to enable so called multilib support, that is building both 32bit and 64bit binaries and libraries (on the same machine). Sure we could use the DIST_TARGET option, but that option would require much more work downstream as it would force us to use per-architecture logic in the script. With the DETECT_USERSPACE flag all "magic" can be handled by our package manager, without any per-arch logic.
I would like to emphasize that no default is changed and that no other flag is removed. The patch merely adds a flag and makes detection conditional preventing machine flags from being appended when DETECT_USERSPACE=False. I would apprecieate if you could consider applying the patch upstream. If you have any questions or suggestions, please let me know! Anyway, here is the patch
Index: SConstruct
===================================================================
--- SConstruct (revision 2584)
+++ SConstruct (working copy)
@@ -76,6 +76,7 @@
BoolVariable( "BUILD_STATIC_TOOLS", "Build a statically linked version of the FFADO tools.", False ),
EnumVariable('DIST_TARGET', 'Build target for cross compiling packagers', 'auto', allowed_values=('auto', 'i386', 'i686', 'x86_64', 'powerpc', 'powerpc64', 'none' ), ignorecase=2),
BoolVariable( "ENABLE_OPTIMIZATIONS", "Enable optimizations and the use of processor specific extentions (MMX/SSE/...).", False ),
+ BoolVariable( "DETECT_USERSPACE", "Try to detect the user space and add necessary machine flags.", True ),
BoolVariable( "PEDANTIC", "Enable -Werror and more pedantic options during compile.", False ),
BoolVariable( "CUSTOM_ENV", "Respect CC, CXX, CFLAGS, CXXFLAGS and LDFLAGS.\nOnly meant for distributors and gentoo-users who want to over-optimize their build.\n Using this is not supported by the ffado-devs!", False ),
( "COMPILE_FLAGS", "Deprecated (use CFLAGS and CXXFLAGS with CUSTOM_ENV=True instead). Add additional flags to the environment.\nOnly meant for distributors and gentoo-users who want to over-optimize their build.\n Using this is not supported by the ffado-devs!" ),
@@ -783,25 +784,26 @@
if '-msse2' in opt_flags:
env['USE_SSE2'] = 1
-m32 = is_userspace_32bit(cpuinfo)
-print 'User space is %s' % (m32 and '32-bit' or '64-bit')
-if cpuinfo.is_powerpc:
- if m32:
- print "Doing a 32-bit PowerPC build for %s CPU" % cpuinfo.ppc_type
- machineflags = { 'CXXFLAGS' : ['-m32'] }
- else:
- print "Doing a 64-bit PowerPC build for %s CPU" % cpuinfo.ppc_type
- machineflags = { 'CXXFLAGS' : ['-m64'] }
- env.MergeFlags( machineflags )
-elif cpuinfo.is_x86:
- if m32:
- print "Doing a 32-bit %s build for %s" % (cpuinfo.machine, cpuinfo.model_name)
- machineflags = { 'CXXFLAGS' : ['-m32'] }
- else:
- print "Doing a 64-bit %s build for %s" % (cpuinfo.machine, cpuinfo.model_name)
- machineflags = { 'CXXFLAGS' : ['-m64'] }
- needs_fPIC = True
- env.MergeFlags( machineflags )
+if env['DETECT_USERSPACE']:
+ m32 = is_userspace_32bit(cpuinfo)
+ print 'User space is %s' % (m32 and '32-bit' or '64-bit')
+ if cpuinfo.is_powerpc:
+ if m32:
+ print "Doing a 32-bit PowerPC build for %s CPU" % cpuinfo.ppc_type
+ machineflags = { 'CXXFLAGS' : ['-m32'] }
+ else:
+ print "Doing a 64-bit PowerPC build for %s CPU" % cpuinfo.ppc_type
+ machineflags = { 'CXXFLAGS' : ['-m64'] }
+ env.MergeFlags( machineflags )
+ elif cpuinfo.is_x86:
+ if m32:
+ print "Doing a 32-bit %s build for %s" % (cpuinfo.machine, cpuinfo.model_name)
+ machineflags = { 'CXXFLAGS' : ['-m32'] }
+ else:
+ print "Doing a 64-bit %s build for %s" % (cpuinfo.machine, cpuinfo.model_name)
+ machineflags = { 'CXXFLAGS' : ['-m64'] }
+ needs_fPIC = True
+ env.MergeFlags( machineflags )
#=== End Revised CXXFLAGS =========================================
[1] http://www.mail-archive.com/proaudio@lists.tuxfamily.org/msg05791.html
Thanks in advance,
Karl