Skip to contentSkip to conversation

sqlite: avoid use of unsupported -Ofast CFLAGS

PATCH New Joshua Henderson 2 participants 2 messages Apr 13, 2018 – Apr 15, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sqlite: avoid use of unsupported -Ofast CFLAGS

sqlite3 refuses to be built with -ffast-math (a side effect of -Ofast) when it falls back to implementing its own isnan() function.

sqlite3.c: In function ?sqlite3IsNaN?:
sqlite3.c:28554:3: error: #error SQLite will not work correctly with the -ffast-math option of GCC.

To work around this, when -Ofast is used replace with -O3.

---
 package/sqlite/sqlite.mk | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
package/sqlite/sqlite.mk +4 -1
index d0030d4..5ae17e1 100644
@@ -39,7 +39,10 @@ ifeq ($(BR2_PACKAGE_SQLITE_NO_SYNC),y)
 SQLITE_CFLAGS += -DSQLITE_NO_SYNC
 endif
 
-SQLITE_CONF_ENV = CFLAGS="$(TARGET_CFLAGS) $(SQLITE_CFLAGS)"
+# fallback to standard -O3 when -Ofast is present to avoid -ffast-math
+SQLITE_CFLAGS += $(subst -Ofast,-O3,$(TARGET_CFLAGS))
+
+SQLITE_CONF_ENV = CFLAGS="$(SQLITE_CFLAGS)"
 
 ifeq ($(BR2_STATIC_LIBS),y)
 SQLITE_CONF_OPTS += --enable-dynamic-extensions=no
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 sqlite: avoid use of unsupported -Ofast CFLAGS

Hello,

Quoted 6 lines · Joshua Henderson

sqlite3 refuses to be built with -ffast-math (a side effect of -Ofast) when it falls back to implementing its own isnan() function.

sqlite3.c: In function ?sqlite3IsNaN?:
sqlite3.c:28554:3: error: #error SQLite will not work correctly with the -ffast-math option of GCC.

Quoted 6 lines

To work around this, when -Ofast is used replace with -O3.

---
 package/sqlite/sqlite.mk | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com