Commit 5b9bbfee authored by gejun's avatar gejun

add --nodebugsymbols to remove -g

parent 573ad3a2
...@@ -7,8 +7,8 @@ include config.mk ...@@ -7,8 +7,8 @@ include config.mk
# 3. Removed -Werror: Not block compilation for non-vital warnings, especially when the # 3. Removed -Werror: Not block compilation for non-vital warnings, especially when the
# code is tested on newer systems. If the code is used in production, add -Werror back # code is tested on newer systems. If the code is used in production, add -Werror back
CPPFLAGS+=-DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__= -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DBRPC_REVISION=\"$(shell git rev-parse --short HEAD)\" CPPFLAGS+=-DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__= -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DBRPC_REVISION=\"$(shell git rev-parse --short HEAD)\"
CXXFLAGS+=$(CPPFLAGS) -g -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer -std=c++0x CXXFLAGS+=$(CPPFLAGS) -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer -std=c++0x
CFLAGS+=$(CPPFLAGS) -g -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-unused-parameter -fno-omit-frame-pointer CFLAGS+=$(CPPFLAGS) -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-unused-parameter -fno-omit-frame-pointer
DEBUG_CXXFLAGS = $(CXXFLAGS) -DUNIT_TEST -DBVAR_NOT_LINK_DEFAULT_VARIABLES DEBUG_CXXFLAGS = $(CXXFLAGS) -DUNIT_TEST -DBVAR_NOT_LINK_DEFAULT_VARIABLES
HDRPATHS=-I./src $(addprefix -I, $(HDRS)) HDRPATHS=-I./src $(addprefix -I, $(HDRS))
LIBPATHS = $(addprefix -L, $(LIBS)) LIBPATHS = $(addprefix -L, $(LIBS))
......
...@@ -17,8 +17,9 @@ else ...@@ -17,8 +17,9 @@ else
LDD=ldd LDD=ldd
fi fi
TEMP=`getopt -o v: --long headers:,libs:,cc:,cxx:,with-glog -n 'config_brpc' -- "$@"` TEMP=`getopt -o v: --long headers:,libs:,cc:,cxx:,with-glog:,nodebugsymbols -n 'config_brpc' -- "$@"`
WITH_GLOG=0 WITH_GLOG=0
DEBUGSYMBOLS=-g
if [ $? != 0 ] ; then >&2 $ECHO "Terminating..."; exit 1 ; fi if [ $? != 0 ] ; then >&2 $ECHO "Terminating..."; exit 1 ; fi
...@@ -33,6 +34,7 @@ while true; do ...@@ -33,6 +34,7 @@ while true; do
--cc ) CC=$2; shift 2 ;; --cc ) CC=$2; shift 2 ;;
--cxx ) CXX=$2; shift 2 ;; --cxx ) CXX=$2; shift 2 ;;
--with-glog ) WITH_GLOG=1; shift 1 ;; --with-glog ) WITH_GLOG=1; shift 1 ;;
--nodebugsymbols ) DEBUGSYMBOLS=; shift 1 ;;
-- ) shift; break ;; -- ) shift; break ;;
* ) break ;; * ) break ;;
esac esac
...@@ -321,7 +323,7 @@ if [ $WITH_GLOG != 0 ]; then ...@@ -321,7 +323,7 @@ if [ $WITH_GLOG != 0 ]; then
rm -f libglog.deps rm -f libglog.deps
fi fi
fi fi
append_to_output "CPPFLAGS+=-DBRPC_WITH_GLOG=$WITH_GLOG -DGFLAGS_NS=$GFLAGS_NS" append_to_output "CPPFLAGS+=-DBRPC_WITH_GLOG=$WITH_GLOG -DGFLAGS_NS=$GFLAGS_NS $DEBUGSYMBOLS"
if [ ! -z "$REQUIRE_UNWIND" ]; then if [ ! -z "$REQUIRE_UNWIND" ]; then
......
# BUILD # BUILD
brpc prefers static linking if possible, so that deps don't have to be installed on every brpc prefers static linking if possible, so that deps don't have to be installed on every machine running the code.
machine running the code.
brpc depends on following packages: brpc depends on following packages:
...@@ -33,7 +32,9 @@ git clone brpc, cd into the repo and run ...@@ -33,7 +32,9 @@ git clone brpc, cd into the repo and run
$ sh config_brpc.sh --headers=/usr/include --libs=/usr/lib $ sh config_brpc.sh --headers=/usr/include --libs=/usr/lib
$ make $ make
``` ```
to change compiler to clang, add `--cxx=clang++ --cc=clang`. To change compiler to clang, add `--cxx=clang++ --cc=clang`.
To not link debugging symbols, add `--nodebugsymbols` and compiled binaries will be much smaller.
### Run example ### Run example
...@@ -63,6 +64,11 @@ Rerun `config_brpc.sh`, `make` in test/, and `sh run_tests.sh` ...@@ -63,6 +64,11 @@ Rerun `config_brpc.sh`, `make` in test/, and `sh run_tests.sh`
### Prepare deps ### Prepare deps
CentOS needs to install EPEL generally otherwise many packages are not available by default.
```
sudo yum install epel-release
```
Install common deps: Install common deps:
``` ```
sudo yum install git g++ make openssl-devel sudo yum install git g++ make openssl-devel
...@@ -80,7 +86,9 @@ git clone brpc, cd into the repo and run ...@@ -80,7 +86,9 @@ git clone brpc, cd into the repo and run
$ sh config_brpc.sh --headers=/usr/include --libs=/usr/lib64 $ sh config_brpc.sh --headers=/usr/include --libs=/usr/lib64
$ make $ make
``` ```
to change compiler to clang, add `--cxx=clang++ --cc=clang`. To change compiler to clang, add `--cxx=clang++ --cc=clang`.
To not link debugging symbols, add `--nodebugsymbols` and compiled binaries will be much smaller.
### Run example ### Run example
...@@ -123,7 +131,9 @@ $ sh config_brpc.sh --headers="../gflags_dev /usr/include" --libs="../gflags_dev ...@@ -123,7 +131,9 @@ $ sh config_brpc.sh --headers="../gflags_dev /usr/include" --libs="../gflags_dev
$ make $ make
``` ```
to change compiler to clang, add `--cxx=clang++ --cc=clang`. To change compiler to clang, add `--cxx=clang++ --cc=clang`.
To not link debugging symbols, add `--nodebugsymbols` and compiled binaries will be much smaller.
Here we pass multiple paths to `--headers` and `--libs` to make the script search for multiple places. You can also group all deps and brpc into one directory, then pass the directory to --headers/--libs which actually search all subdirectories recursively and will find necessary files. Here we pass multiple paths to `--headers` and `--libs` to make the script search for multiple places. You can also group all deps and brpc into one directory, then pass the directory to --headers/--libs which actually search all subdirectories recursively and will find necessary files.
......
...@@ -3,7 +3,7 @@ include $(BRPC_PATH)/config.mk ...@@ -3,7 +3,7 @@ include $(BRPC_PATH)/config.mk
# Notes on the flags: # Notes on the flags:
# 1. Added -fno-omit-frame-pointer: perf/tcmalloc-profiler use frame pointers by default # 1. Added -fno-omit-frame-pointer: perf/tcmalloc-profiler use frame pointers by default
# 2. Added -D__const__= : Avoid over-optimizations of TLS variables by GCC>=4.8 # 2. Added -D__const__= : Avoid over-optimizations of TLS variables by GCC>=4.8
CXXFLAGS+=$(CPPFLAGS) -std=c++0x -g -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Werror -Wno-unused-parameter -fPIC -fno-omit-frame-pointer CXXFLAGS+=$(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Werror -Wno-unused-parameter -fPIC -fno-omit-frame-pointer
HDRS+=$(BRPC_PATH)/output/include HDRS+=$(BRPC_PATH)/output/include
LIBS+=$(BRPC_PATH)/output/lib LIBS+=$(BRPC_PATH)/output/lib
HDRPATHS = $(addprefix -I, $(HDRS)) HDRPATHS = $(addprefix -I, $(HDRS))
......
...@@ -4,7 +4,7 @@ include $(BRPC_PATH)/config.mk ...@@ -4,7 +4,7 @@ include $(BRPC_PATH)/config.mk
# Notes on the flags: # Notes on the flags:
# 1. Added -fno-omit-frame-pointer: perf/tcmalloc-profiler use frame pointers by default # 1. Added -fno-omit-frame-pointer: perf/tcmalloc-profiler use frame pointers by default
# 2. Added -D__const__= : Avoid over-optimizations of TLS variables by GCC>=4.8 # 2. Added -D__const__= : Avoid over-optimizations of TLS variables by GCC>=4.8
CXXFLAGS+=$(CPPFLAGS) -std=c++0x -g -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Werror -Wno-unused-parameter -fPIC -fno-omit-frame-pointer CXXFLAGS+=$(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Werror -Wno-unused-parameter -fPIC -fno-omit-frame-pointer
ifeq ($(NEED_GPERFTOOLS), 1) ifeq ($(NEED_GPERFTOOLS), 1)
CXXFLAGS+=-DBRPC_ENABLE_CPU_PROFILER CXXFLAGS+=-DBRPC_ENABLE_CPU_PROFILER
endif endif
......
BRPC_PATH = ../../ BRPC_PATH = ../../
include $(BRPC_PATH)/config.mk include $(BRPC_PATH)/config.mk
CXXFLAGS+=$(CPPFLAGS) -std=c++0x -g -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Werror -fPIC -fno-omit-frame-pointer CXXFLAGS+=$(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Werror -fPIC -fno-omit-frame-pointer
HDRS+=$(BRPC_PATH)/output/include HDRS+=$(BRPC_PATH)/output/include
LIBS+=$(BRPC_PATH)/output/lib LIBS+=$(BRPC_PATH)/output/lib
HDRPATHS = $(addprefix -I, $(HDRS)) HDRPATHS = $(addprefix -I, $(HDRS))
......
...@@ -4,7 +4,7 @@ include $(BRPC_PATH)/config.mk ...@@ -4,7 +4,7 @@ include $(BRPC_PATH)/config.mk
# Notes on the flags: # Notes on the flags:
# 1. Added -fno-omit-frame-pointer: perf/tcmalloc-profiler use frame pointers by default # 1. Added -fno-omit-frame-pointer: perf/tcmalloc-profiler use frame pointers by default
# 2. Added -D__const__= : Avoid over-optimizations of TLS variables by GCC>=4.8 # 2. Added -D__const__= : Avoid over-optimizations of TLS variables by GCC>=4.8
CXXFLAGS+=$(CPPFLAGS) -std=c++0x -g -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Werror -Wno-unused-parameter -fPIC -fno-omit-frame-pointer CXXFLAGS+=$(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Werror -Wno-unused-parameter -fPIC -fno-omit-frame-pointer
ifeq ($(NEED_GPERFTOOLS), 1) ifeq ($(NEED_GPERFTOOLS), 1)
CXXFLAGS+=-DBRPC_ENABLE_CPU_PROFILER CXXFLAGS+=-DBRPC_ENABLE_CPU_PROFILER
endif endif
......
BRPC_PATH = ../../ BRPC_PATH = ../../
include $(BRPC_PATH)/config.mk include $(BRPC_PATH)/config.mk
CXXFLAGS+=$(CPPFLAGS) -std=c++0x -g -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Werror -fPIC -fno-omit-frame-pointer CXXFLAGS+=$(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Werror -fPIC -fno-omit-frame-pointer
HDRS+=$(BRPC_PATH)/output/include HDRS+=$(BRPC_PATH)/output/include
LIBS+=$(BRPC_PATH)/output/lib LIBS+=$(BRPC_PATH)/output/lib
HDRPATHS = $(addprefix -I, $(HDRS)) HDRPATHS = $(addprefix -I, $(HDRS))
......
...@@ -3,7 +3,7 @@ NEED_GTEST=1 ...@@ -3,7 +3,7 @@ NEED_GTEST=1
include ../config.mk include ../config.mk
CPPFLAGS+=-DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__= -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS CPPFLAGS+=-DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__= -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS
CPPFLAGS+=-DUNIT_TEST -Dprivate=public -Dprotected=public -DBVAR_NOT_LINK_DEFAULT_VARIABLES --include sstream_workaround.h CPPFLAGS+=-DUNIT_TEST -Dprivate=public -Dprotected=public -DBVAR_NOT_LINK_DEFAULT_VARIABLES --include sstream_workaround.h
CXXFLAGS+=$(CPPFLAGS) -g -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer -std=c++0x CXXFLAGS+=$(CPPFLAGS) -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer -std=c++0x
#required by butil/crc32.cc to boost performance for 10x #required by butil/crc32.cc to boost performance for 10x
ifeq ($(shell test $(GCC_VERSION) -ge 40400; echo $$?),0) ifeq ($(shell test $(GCC_VERSION) -ge 40400; echo $$?),0)
......
BRPC_PATH = ../../ BRPC_PATH = ../../
include $(BRPC_PATH)/config.mk include $(BRPC_PATH)/config.mk
CXXFLAGS = $(CPPFLAGS) -std=c++0x -g -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Werror -fPIC -fno-omit-frame-pointer -Wno-unused-parameter CXXFLAGS = $(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Werror -fPIC -fno-omit-frame-pointer -Wno-unused-parameter
HDRPATHS = -I$(BRPC_PATH)/output/include $(addprefix -I, $(HDRS)) HDRPATHS = -I$(BRPC_PATH)/output/include $(addprefix -I, $(HDRS))
LIBPATHS = -L$(BRPC_PATH)/output/lib $(addprefix -L, $(LIBS)) LIBPATHS = -L$(BRPC_PATH)/output/lib $(addprefix -L, $(LIBS))
STATIC_LINKINGS += -lbrpc STATIC_LINKINGS += -lbrpc
......
BRPC_PATH = ../../ BRPC_PATH = ../../
include $(BRPC_PATH)/config.mk include $(BRPC_PATH)/config.mk
CXXFLAGS = $(CPPFLAGS) -std=c++0x -g -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Werror -fPIC -fno-omit-frame-pointer -Wno-unused-parameter CXXFLAGS = $(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Werror -fPIC -fno-omit-frame-pointer -Wno-unused-parameter
HDRPATHS = -I$(BRPC_PATH)/output/include $(addprefix -I, $(HDRS)) HDRPATHS = -I$(BRPC_PATH)/output/include $(addprefix -I, $(HDRS))
LIBPATHS = -L$(BRPC_PATH)/output/lib $(addprefix -L, $(LIBS)) LIBPATHS = -L$(BRPC_PATH)/output/lib $(addprefix -L, $(LIBS))
STATIC_LINKINGS += -lbrpc STATIC_LINKINGS += -lbrpc
......
BRPC_PATH = ../../ BRPC_PATH = ../../
include $(BRPC_PATH)/config.mk include $(BRPC_PATH)/config.mk
CXXFLAGS = $(CPPFLAGS) -std=c++0x -g -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Werror -fPIC -fno-omit-frame-pointer -Wno-unused-parameter CXXFLAGS = $(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Werror -fPIC -fno-omit-frame-pointer -Wno-unused-parameter
HDRPATHS = -I$(BRPC_PATH)/output/include $(addprefix -I, $(HDRS)) HDRPATHS = -I$(BRPC_PATH)/output/include $(addprefix -I, $(HDRS))
LIBPATHS = -L$(BRPC_PATH)/output/lib $(addprefix -L, $(LIBS)) LIBPATHS = -L$(BRPC_PATH)/output/lib $(addprefix -L, $(LIBS))
STATIC_LINKINGS += -lbrpc STATIC_LINKINGS += -lbrpc
......
...@@ -3,7 +3,7 @@ include $(BRPC_PATH)/config.mk ...@@ -3,7 +3,7 @@ include $(BRPC_PATH)/config.mk
# Notes on the flags: # Notes on the flags:
# 1. Added -fno-omit-frame-pointer: perf/tcmalloc-profiler use frame pointers by default # 1. Added -fno-omit-frame-pointer: perf/tcmalloc-profiler use frame pointers by default
# 2. Added -D__const__= : Avoid over-optimizations of TLS variables by GCC>=4.8 # 2. Added -D__const__= : Avoid over-optimizations of TLS variables by GCC>=4.8
CXXFLAGS = $(CPPFLAGS) -std=c++0x -g -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Werror -Wno-unused-parameter -fPIC -fno-omit-frame-pointer CXXFLAGS = $(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Werror -Wno-unused-parameter -fPIC -fno-omit-frame-pointer
HDRPATHS = -I$(BRPC_PATH)/output/include $(addprefix -I, $(HDRS)) HDRPATHS = -I$(BRPC_PATH)/output/include $(addprefix -I, $(HDRS))
LIBPATHS = -L$(BRPC_PATH)/output/lib $(addprefix -L, $(LIBS)) LIBPATHS = -L$(BRPC_PATH)/output/lib $(addprefix -L, $(LIBS))
STATIC_LINKINGS += -lbrpc STATIC_LINKINGS += -lbrpc
......
BRPC_PATH = ../../ BRPC_PATH = ../../
include $(BRPC_PATH)/config.mk include $(BRPC_PATH)/config.mk
CXXFLAGS = $(CPPFLAGS) -std=c++0x -g -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Werror -fPIC -fno-omit-frame-pointer CXXFLAGS = $(CPPFLAGS) -std=c++0x -DNDEBUG -O2 -D__const__= -pipe -W -Wall -Werror -fPIC -fno-omit-frame-pointer
HDRPATHS = -I$(BRPC_PATH)/output/include $(addprefix -I, $(HDRS)) HDRPATHS = -I$(BRPC_PATH)/output/include $(addprefix -I, $(HDRS))
LIBPATHS = -L$(BRPC_PATH)/output/lib $(addprefix -L, $(LIBS)) LIBPATHS = -L$(BRPC_PATH)/output/lib $(addprefix -L, $(LIBS))
STATIC_LINKINGS += -lbrpc STATIC_LINKINGS += -lbrpc
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment