Skip to content

Commit

Permalink
Use LTO to further reduce binary size.
Browse files Browse the repository at this point in the history
  • Loading branch information
Artefact2 committed Apr 22, 2017
1 parent d8c4b94 commit 95d4207
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
build/
build*
examples/xmgl/vs.h
examples/xmgl/fs.h
7 changes: 1 addition & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,8 @@ ADD_DEFINITIONS("-g")
ENDIF()

IF(XM_DEMO_MODE)
ADD_DEFINITIONS("-Os")
ADD_DEFINITIONS("-fdata-sections -ffunction-sections")
IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -dead_strip")
ELSE()
ADD_DEFINITIONS("-Os -fdata-sections -ffunction-sections -flto -fuse-linker-plugin")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
ENDIF()
ELSE()
ADD_DEFINITIONS("-O2")
ENDIF()
Expand Down
15 changes: 8 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
build-debug: build
@cd build && cmake -D XM_DEBUG=ON -D XM_DEFENSIVE=ON ..
build: build-debug build-prod

build-demo: build
@cd build && cmake -D XM_DEBUG=OFF -D XM_DEFENSIVE=OFF -D XM_DEMO_MODE=ON ..
build-debug:
mkdir $@
@cd $@ && CC=gcc cmake -D XM_DEBUG=ON -D XM_DEFENSIVE=ON -D XM_DEMO_MODE=OFF ..

build:
@mkdir -p build
build-prod:
mkdir $@
@cd $@ && CC=gcc cmake -D XM_DEBUG=OFF -D XM_DEFENSIVE=OFF -D XM_DEMO_MODE=ON ..

dist-clean:
@rm -Rf build
@rm -Rf build-debug build-prod

.PHONY: build dist-clean
8 changes: 5 additions & 3 deletions examples/xmgl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
FIND_PACKAGE(PkgConfig)

FIND_PACKAGE(OpenGL)

IF(${PKG_CONFIG_FOUND})
PKG_SEARCH_MODULE(GLFW glfw3)
PKG_SEARCH_MODULE(JACK jack)
IF(${GLFW_FOUND} AND ${JACK_FOUND})
IF(${GLFW_FOUND} AND ${JACK_FOUND} AND ${OPENGL_FOUND})

ADD_EXECUTABLE(filetoh filetoh.c)

ADD_CUSTOM_COMMAND(OUTPUT vs.h COMMAND filetoh vs vs.c DEPENDS filetoh vs.c WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
ADD_CUSTOM_COMMAND(OUTPUT fs.h COMMAND filetoh fs fs.c DEPENDS filetoh fs.c WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})

ADD_EXECUTABLE(xmgl xmgl.c vs.h fs.h)
INCLUDE_DIRECTORIES(${GLFW_INCLUDE_DIRS} ${JACK_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(xmgl ${JACK_LIBRARIES} ${XM_LIBRARIES} xms ${GLFW_STATIC_LIBRARIES})
INCLUDE_DIRECTORIES(${GLFW_INCLUDE_DIRS} ${JACK_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(xmgl ${JACK_LIBRARIES} ${XM_LIBRARIES} xms ${OPENGL_gl_LIBRARY} ${GLFW_LIBRARIES})

ENDIF()
ENDIF()
2 changes: 1 addition & 1 deletion examples/xmtowav.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

static const unsigned int channels = 2;
static const unsigned int rate = 48000;
static const size_t buffer_size = rate;
static const size_t buffer_size = 48000;

void puts_uint32_le(uint32_t i, FILE* f) {
char* c = (char*)(&i);
Expand Down

0 comments on commit 95d4207

Please sign in to comment.