[PATCH] detect if host cc accepts -malign-double

  • From: Tony Theodore <tony.theodore@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Mon, 6 Oct 2014 00:23:12 +1100

Hi,

When cross-compiling for Windows on OSX, `gcc` is an alias for `clang` and 
doesn’t accept the `-malign-double` argument. The patch below fixes this.

Cheers,

Tony


diff --git a/src/Makefile b/src/Makefile
index 9551781..682260e 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -167,6 +167,7 @@ CCOPTIONS= $(CCDEBUG) $(CCOPT) $(CCWARN) $(XCFLAGS) 
$(CFLAGS)
 LDOPTIONS= $(CCDEBUG) $(LDFLAGS)
 
 HOST_CC= $(CC)
+HOST_CC_MALIGN_DOUBLE= $(shell $(HOST_CC) -malign-double -v > /dev/null 2>&1 
&& echo -malign-double)
 HOST_RM= rm -f
 # If left blank, minilua is built and used. You can supply an installed
 # copy of (plain) Lua 5.1 or 5.2, plus Lua BitOp. E.g. with: HOST_LUA=lua
@@ -333,7 +334,7 @@ endif
 
 ifneq ($(HOST_SYS),$(TARGET_SYS))
   ifeq (Windows,$(TARGET_SYS))
-    HOST_XCFLAGS+= -malign-double -DLUAJIT_OS=LUAJIT_OS_WINDOWS
+    HOST_XCFLAGS+= $(HOST_CC_MALIGN_DOUBLE) -DLUAJIT_OS=LUAJIT_OS_WINDOWS
   else
   ifeq (Linux,$(TARGET_SYS))
     HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_LINUX
-- 
1.9.3

Other related posts:

  • » [PATCH] detect if host cc accepts -malign-double - Tony Theodore