diff mbox

[3/6] xfsprogs: define and use BUILD_CC in configure.ac for cross compilation

Message ID 1437913255-7524-4-git-send-email-tytso@mit.edu (mailing list archive)
State New, archived
Headers show

Commit Message

Theodore Ts'o July 26, 2015, 12:20 p.m. UTC
In order to support cross-compilation, we need to build gen_crc32table
using the C compiler targetted for the build platform, since it is run
as part of the build process.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
 configure.ac         | 8 ++++++++
 include/builddefs.in | 1 +
 libxfs/Makefile      | 4 ++--
 3 files changed, 11 insertions(+), 2 deletions(-)

Comments

Christoph Hellwig July 30, 2015, 5:10 p.m. UTC | #1
Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>
--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Gwendal Grignou Jan. 30, 2016, 12:58 a.m. UTC | #2
Theodore Ts'o <tytso <at> mit.edu> writes:


> -	$(Q) $(CC) $(CFLAGS) -o gen_crc32table $<
> +	$(Q) $(BUILD_CC) $(CFLAGS) -o gen_crc32table $<

Try to cross compile to armv7a, but I hit a compilation failure for 
gen_crc32table.c:
gcc.real: error: unrecognized command line option '-mfpu=neon'
gcc.real: error: unrecognized command line option '-mfloat-abi=hard'

The problem is CFLAGS is set up for the cross compiler (armv7a-cros-linux-
gnueabi-gcc) and some options does not work on the native compiler.

(CFLAGS is " -O2 -O2 -pipe -march=armv7-a -mtune=cortex-a15 -mfpu=neon -
mfloat-abi=hard -g -fno-exceptions -fno-unwind-tables -fno-asynchronous-
unwind-tables")

Looking into defining BUILD_CFLAGS.

Gwendal.



--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/configure.ac b/configure.ac
index ae17c68..4cfbd4e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -8,6 +8,14 @@  AC_PREFIX_DEFAULT(/usr)
 
 AC_PROG_LIBTOOL
 
+AC_PROG_CC
+if test $cross_compiling = no; then
+  BUILD_CC="$CC"
+  AC_SUBST(BUILD_CC)
+else
+  AC_CHECK_PROGS(BUILD_CC, gcc cc)
+fi
+
 AC_ARG_ENABLE(shared,
 [ --enable-shared=[yes/no] Enable use of shared libraries [default=yes]],,
 	enable_shared=yes)
diff --git a/include/builddefs.in b/include/builddefs.in
index 7e9f53d..1d2d22e 100644
--- a/include/builddefs.in
+++ b/include/builddefs.in
@@ -64,6 +64,7 @@  PKG_DOC_DIR	= @datadir@/doc/@pkg_name@
 PKG_LOCALE_DIR	= @datadir@/locale
 
 CC		= @cc@
+BUILD_CC	= @BUILD_CC@
 AWK		= @awk@
 SED		= @sed@
 TAR		= @tar@
diff --git a/libxfs/Makefile b/libxfs/Makefile
index ae15a5d..6323b81 100644
--- a/libxfs/Makefile
+++ b/libxfs/Makefile
@@ -67,7 +67,7 @@  default: crc32selftest ltdepend $(LTLIBRARY)
 
 crc32table.h: gen_crc32table.c
 	@echo "    [CC]     gen_crc32table"
-	$(Q) $(CC) $(CFLAGS) -o gen_crc32table $<
+	$(Q) $(BUILD_CC) $(CFLAGS) -o gen_crc32table $<
 	@echo "    [GENERATE] $@"
 	$(Q) ./gen_crc32table > crc32table.h
 
@@ -78,7 +78,7 @@  crc32table.h: gen_crc32table.c
 # disk.
 crc32selftest: gen_crc32table.c crc32table.h crc32.c
 	@echo "    [TEST]    CRC32"
-	$(Q) $(CC) $(CFLAGS) -D CRC32_SELFTEST=1 crc32.c -o $@
+	$(Q) $(BUILD_CC) $(CFLAGS) -D CRC32_SELFTEST=1 crc32.c -o $@
 	$(Q) ./$@
 
 include $(BUILDRULES)