1
0
Fork 0
forked from forks/qmk_firmware

[Core] Update C standard to GNU11, C++ to GNU++14 (#17114)

This commit is contained in:
Stefan Kerkmann 2022-06-06 00:47:22 +02:00 committed by GitHub
parent 6221c86186
commit e89478eb0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 110 deletions

View file

@ -1,19 +1,5 @@
# Hey Emacs, this is a -*- makefile -*- # Hey Emacs, this is a -*- makefile -*-
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# WinAVR Makefile Template written by Eric B. Weddington, Jg Wunsch, et al.
#
# Released to the Public Domain
#
# Additional material for this makefile was written by:
# Peter Fleury
# Tim Henigan
# Colin O'Flynn
# Reiner Patommel
# Markus Pfaff
# Sander Pool
# Frederik Rouleau
# Carlos Lamas
#
# Enable vpath seraching for source files only # Enable vpath seraching for source files only
# Without this, output files, could be read from the wrong .build directories # Without this, output files, could be read from the wrong .build directories
@ -38,36 +24,15 @@ NO_LTO_OBJ := $(filter %.a,$(OBJ))
MASTER_OUTPUT := $(firstword $(OUTPUTS)) MASTER_OUTPUT := $(firstword $(OUTPUTS))
# Output format. (can be srec, ihex, binary) # Output format. (can be srec, ihex, binary)
FORMAT = ihex FORMAT = ihex
# Optimization level, can be [0, 1, 2, 3, s]. # Optimization level, can be [0, 1, 2, 3, s].
# 0 = turn off optimization. s = optimize for size.
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
OPT ?= s OPT ?= s
# Compiler flag to set the C Standard level. # Compiler flag to set the C and C++ language standard level
# c89 = "ANSI" C CSTANDARD = -std=gnu11
# gnu89 = c89 plus GCC extensions CXXSTANDARD = -std=gnu++14
# c99 = ISO C99 standard (not yet fully implemented)
# gnu99 = c99 plus GCC extensions
CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
#CDEFS +=
# Place -D or -U options here for ASM sources
#ADEFS +=
# Place -D or -U options here for C++ sources
#CXXDEFS += -D__STDC_LIMIT_MACROS
#CXXDEFS += -D__STDC_CONSTANT_MACROS
#CXXDEFS +=
# Speed up recompilations by opt-in usage of ccache # Speed up recompilations by opt-in usage of ccache
USE_CCACHE ?= no USE_CCACHE ?= no
@ -75,12 +40,8 @@ ifneq ($(USE_CCACHE),no)
CC_PREFIX ?= ccache CC_PREFIX ?= ccache
endif endif
#---------------- Compiler Options C ---------------- #---------------- C Compiler Options ----------------
# -g*: generate debugging information
# -O*: optimization level
# -f...: tuning, see GCC manual and avr-libc documentation
# -Wall...: warning level
# -Wa,...: tell GCC to pass this to the assembler.
ifeq ($(strip $(LTO_ENABLE)), yes) ifeq ($(strip $(LTO_ENABLE)), yes)
ifeq ($(PLATFORM),ARM_ATSAM) ifeq ($(PLATFORM),ARM_ATSAM)
$(info Enabling LTO on arm_atsam-targeting boards is known to have a high likelihood of failure.) $(info Enabling LTO on arm_atsam-targeting boards is known to have a high likelihood of failure.)
@ -111,23 +72,14 @@ CFLAGS += -Wstrict-prototypes
ifneq ($(strip $(ALLOW_WARNINGS)), yes) ifneq ($(strip $(ALLOW_WARNINGS)), yes)
CFLAGS += -Werror CFLAGS += -Werror
endif endif
#CFLAGS += -mshort-calls
#CFLAGS += -fno-unit-at-a-time
#CFLAGS += -Wundef
#CFLAGS += -Wunreachable-code
#CFLAGS += -Wsign-compare
CFLAGS += $(CSTANDARD) CFLAGS += $(CSTANDARD)
# This fixes lots of keyboards linking errors but SHOULDN'T BE A FINAL SOLUTION # This fixes lots of keyboards linking errors but SHOULDN'T BE A FINAL SOLUTION
# Fixing of multiple variable definitions must be made. # Fixing of multiple variable definitions must be made.
CFLAGS += -fcommon CFLAGS += -fcommon
#---------------- Compiler Options C++ ---------------- #---------------- C++ Compiler Options ----------------
# -g*: generate debugging information
# -O*: optimization level
# -f...: tuning, see GCC manual and avr-libc documentation
# -Wall...: warning level
# -Wa,...: tell GCC to pass this to the assembler.
ifeq ($(strip $(DEBUG_ENABLE)),yes) ifeq ($(strip $(DEBUG_ENABLE)),yes)
CXXFLAGS += -g$(DEBUG) CXXFLAGS += -g$(DEBUG)
endif endif
@ -141,57 +93,17 @@ CXXFLAGS += -Wundef
ifneq ($(strip $(ALLOW_WARNINGS)), yes) ifneq ($(strip $(ALLOW_WARNINGS)), yes)
CXXFLAGS += -Werror CXXFLAGS += -Werror
endif endif
#CXXFLAGS += -mshort-calls
#CXXFLAGS += -fno-unit-at-a-time
#CXXFLAGS += -Wstrict-prototypes
#CXXFLAGS += -Wunreachable-code
#CXXFLAGS += -Wsign-compare
#CXXFLAGS += $(CSTANDARD)
#---------------- Assembler Options ---------------- #---------------- Assembler Options ----------------
ASFLAGS += $(ADEFS) ASFLAGS += $(ADEFS)
ifeq ($(VERBOSE_AS_CMD),yes) ifeq ($(VERBOSE_AS_CMD),yes)
ASFLAGS += -v ASFLAGS += -v
endif endif
#---------------- Library Options ----------------
# Minimalistic printf version
PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
# Floating point printf version (requires MATH_LIB = -lm below)
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
# If this is left blank, then it will use the Standard printf version.
PRINTF_LIB =
#PRINTF_LIB = $(PRINTF_LIB_MIN)
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
# Minimalistic scanf version
SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
# If this is left blank, then it will use the Standard scanf version.
SCANF_LIB =
#SCANF_LIB = $(SCANF_LIB_MIN)
#SCANF_LIB = $(SCANF_LIB_FLOAT)
MATH_LIB = -lm
CREATE_MAP ?= yes
#---------------- Linker Options ---------------- #---------------- Linker Options ----------------
# -Wl,...: tell GCC to pass this to linker.
# -Map: create map file
# --cref: add cross reference to map file
#
# Comennt out "--relax" option to avoid a error such:
# (.vectors+0x30): relocation truncated to fit: R_AVR_13_PCREL against symbol `__vector_12'
#
CREATE_MAP ?= yes
ifeq ($(CREATE_MAP),yes) ifeq ($(CREATE_MAP),yes)
LDFLAGS += -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref LDFLAGS += -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref
endif endif
@ -201,20 +113,11 @@ endif
#LDFLAGS += -Wl,--relax #LDFLAGS += -Wl,--relax
LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(EXTMEMOPTS)
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) LDFLAGS += -lm
#LDFLAGS += -T linker_script.x
# You can give EXTRALDFLAGS at 'make' command line. # You can give EXTRALDFLAGS at 'make' command line.
LDFLAGS += $(EXTRALDFLAGS) LDFLAGS += $(EXTRALDFLAGS)
#---------------- Assembler Listings ---------------- #---------------- Assembler Listings ----------------
# -Wa,...: tell GCC to pass this to the assembler.
# -adhlns: create listing
# -gstabs: have the assembler create line number information; note that
# for use in COFF files, additional information about filenames
# and function names needs to be present in the assembler source
# files -- see avr-libc docs [FIXME: not yet described there]
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
# dump that will be displayed for a given single line of source input.
ADHLNS_ENABLE ?= no ADHLNS_ENABLE ?= no
ifeq ($(ADHLNS_ENABLE),yes) ifeq ($(ADHLNS_ENABLE),yes)

View file

@ -30,7 +30,7 @@ COMPILEFLAGS += -mthumb
CFLAGS += $(COMPILEFLAGS) CFLAGS += $(COMPILEFLAGS)
CXXFLAGS += $(COMPILEFLAGS) CXXFLAGS += $(COMPILEFLAGS)
CXXFLAGS += -fno-exceptions -std=c++11 CXXFLAGS += -fno-exceptions $(CXXSTANDARD)
LDFLAGS +=-Wl,--gc-sections LDFLAGS +=-Wl,--gc-sections
LDFLAGS += -Wl,-Map="%OUT%%PROJ_NAME%.map" LDFLAGS += -Wl,-Map="%OUT%%PROJ_NAME%.map"

View file

@ -38,7 +38,7 @@ CFLAGS += -fno-inline-small-functions
CFLAGS += -fno-strict-aliasing CFLAGS += -fno-strict-aliasing
CXXFLAGS += $(COMPILEFLAGS) CXXFLAGS += $(COMPILEFLAGS)
CXXFLAGS += -fno-exceptions -std=c++11 CXXFLAGS += -fno-exceptions $(CXXSTANDARD)
LDFLAGS += -Wl,--gc-sections LDFLAGS += -Wl,--gc-sections

View file

@ -31,4 +31,4 @@ CFLAGS += -fno-strict-aliasing
CXXFLAGS += $(COMPILEFLAGS) CXXFLAGS += $(COMPILEFLAGS)
CXXFLAGS += -fno-exceptions CXXFLAGS += -fno-exceptions
CXXFLAGS += -std=gnu++11 CXXFLAGS += $(CXXSTANDARD)