From 12cf9df01b72898d2138de95dc2efd8afa880ac9 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Mon, 13 May 2024 12:55:29 +0200 Subject: [PATCH 1/2] port: allow overriding CC and CXX --- Makefile.port | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Makefile.port b/Makefile.port index d6a6699d4..550b7cb60 100644 --- a/Makefile.port +++ b/Makefile.port @@ -151,9 +151,15 @@ G_DIR := src/generated/$(ROMID) ifneq (,$(findstring windows,$(TARGET_PLATFORM))) TARGET_CFLAGS := $(shell pkg-config sdl2 --cflags-only-I) - TARGET_LDFLAGS := $(shell pkg-config sdl2 --libs) -lz -lopengl32 -static-libstdc++ -ldbghelp + TARGET_LDFLAGS := $(shell pkg-config sdl2 --libs) -lz -lopengl32 -ldbghelp # on windows/mingw we need this to be built with a 32-bit compiler so it finds the correct libs TOOLCHAIN ?= i686-w64-mingw32- + # on GCC link libstdc++ statically + ifeq (,$(findstring clang,$(CC))$(findstring clang,$(CXX))) + TARGET_LDFLAGS += -static-libstdc++ + else + TARGET_LDFLAGS += -lstdc++ + endif else # assume *nix TARGET_CFLAGS := $(shell pkg-config sdl2 --cflags-only-I) TARGET_LDFLAGS := $(shell pkg-config sdl2 --libs) -lGL -lz -ldl @@ -162,6 +168,10 @@ else # assume *nix # TODO: detect soft/hardfloat abi TOOLCHAIN ?= arm-linux-gnueabihf- endif + # on clang link libc++ + ifneq (,$(findstring clang,$(CC))$(findstring clang,$(CXX))) + TARGET_LDFLAGS += -lc++ + endif endif # On x86_64 gcc add -m32 to CFLAGS if building a 32-bit executable. @@ -233,8 +243,8 @@ INCLUDES = \ -I port/include TOOLCHAIN ?= -CC := $(TOOLCHAIN)gcc -std=c11 -CXX := $(TOOLCHAIN)g++ -std=c++20 +CC ?= $(TOOLCHAIN)gcc +CXX ?= $(TOOLCHAIN)g++ ifneq (,$(CXX_O_FILES)) LD := $(CXX) else @@ -250,7 +260,6 @@ COMMON_CFLAGS := $(C_DEFINES) -DAVOID_UB=1 $(INCLUDES) $(TARGET_CFLAGS) -g \ -fwrapv \ -Wall \ -Wno-address \ - -Wno-aggressive-loop-optimizations \ -Wno-int-in-bool-context \ -Wno-misleading-indentation \ -Wno-missing-braces \ @@ -261,8 +270,8 @@ COMMON_CFLAGS := $(C_DEFINES) -DAVOID_UB=1 $(INCLUDES) $(TARGET_CFLAGS) -g \ -Wno-unused-variable \ -Wno-format-truncation -CFLAGS := $(COMMON_CFLAGS) -Wno-pointer-sign -CXXFLAGS := $(COMMON_CFLAGS) -Wno-unused-function +CFLAGS := -std=c11 $(COMMON_CFLAGS) -Wno-pointer-sign +CXXFLAGS := -std=c++20 $(COMMON_CFLAGS) -Wno-unused-function LDFLAGS := $(TARGET_LDFLAGS) # Make ROMID available as an environment variable to all tooling. From 62a55a3d6e1b0e74916b69436794ff22f77f55ff Mon Sep 17 00:00:00 2001 From: fgsfds Date: Mon, 13 May 2024 15:24:45 +0200 Subject: [PATCH 2/2] port: don't force libc++, fix system.c on clang16+ --- Makefile.port | 4 ---- port/src/system.c | 8 ++++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Makefile.port b/Makefile.port index 550b7cb60..650f02474 100644 --- a/Makefile.port +++ b/Makefile.port @@ -168,10 +168,6 @@ else # assume *nix # TODO: detect soft/hardfloat abi TOOLCHAIN ?= arm-linux-gnueabihf- endif - # on clang link libc++ - ifneq (,$(findstring clang,$(CC))$(findstring clang,$(CXX))) - TARGET_LDFLAGS += -lc++ - endif endif # On x86_64 gcc add -m32 to CFLAGS if building a 32-bit executable. diff --git a/port/src/system.c b/port/src/system.c index 36f9475ce..16b689c47 100644 --- a/port/src/system.c +++ b/port/src/system.c @@ -1,3 +1,7 @@ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif + #include #include #include @@ -28,10 +32,6 @@ __attribute__((dllexport)) u32 AmdPowerXpressRequestHighPerformance = 1; #else -#ifndef _GNU_SOURCE -#define _GNU_SOURCE 1 -#endif - #include // figure out how to yield