Skip to content

Commit

Permalink
Makefile: Adjust compiler flags specifically for cosmoc++
Browse files Browse the repository at this point in the history
Disable flto

Disable flto
  • Loading branch information
eric15342335 committed Jun 8, 2024
1 parent 4dc2a80 commit 132360c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/make.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ jobs:
- {os: windows-latest, CXX: clang++, build_type: all}
- {os: windows-latest, CXX: clang++, build_type: release}
- {os: windows-latest, CXX: cmake, build_type: Debug}
- {os: windows-latest, CXX: cosmoc++, build_type: all}
- {os: windows-latest, CXX: cosmoc++, build_type: release}
# macos-12 is for x64, while macos-14 is for arm64 (M1)
- {os: macos-12, CXX: g++, build_type: all}
- {os: macos-12, CXX: g++, build_type: release}
Expand Down Expand Up @@ -64,7 +66,7 @@ jobs:
with:
arch: amd64
- name: Setup cosmoc++
if: matrix.config.CXX == 'cosmoc++' && matrix.config.os == 'ubuntu-latest'
if: matrix.config.CXX == 'cosmoc++'
run: |
mkdir -p cosmocc
cd cosmocc
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ endif

# Security flags for Linux
ifeq ($(shell uname),Linux)
ifneq ($(CXX),cosmoc++)
CXXFLAGS += -z noexecstack -z relro -z now
endif
endif

# Shhh clang++
ifeq ($(CXX),clang++)
Expand Down Expand Up @@ -151,17 +153,20 @@ check:
--fix-errors --fix-notes --format-style=file -- -Iinclude

ifeq ($(MAKECMDGOALS),release)
ifneq ($(CXX),cosmoc++)
CXXFLAGS += -fstack-protector-strong
ifneq ($(CXX),clang++)
CXXFLAGS += -flto
else ifneq ($(OS),Windows_NT)
CXXFLAGS += -flto
endif
endif
endif

release: clean
# this should put after default target
"$(MAKE)" stocksim \
CXXFLAGS="$(CXXFLAGS) -O3 -D_FORTIFY_SOURCE=2 -fstack-protector-strong" \
CXXFLAGS="$(CXXFLAGS) -O3 -D_FORTIFY_SOURCE=2" \
OUTPUT="stocksim-release" \
CXX="$(CXX)"

Expand Down

0 comments on commit 132360c

Please sign in to comment.