diff --git a/build.sh b/build.sh index a8ad3f1b4..4de8acaea 100755 --- a/build.sh +++ b/build.sh @@ -31,6 +31,7 @@ function print_help() -T|--tassl build with tassl -pm|--product_mode this values of paramenter is opengauss or lite or finance, the default value is opengauss. -nls|--enable_nls enable Native Language Support + --relocation generate gaussdb.map with relocation(GCC >=10.3). " } @@ -82,7 +83,11 @@ while [ $# -gt 0 ]; do shift 1 ;; -nls|--enable_nls) - extra_config_opt="--config_opt --enable-nls=zh_CN " + extra_config_opt="$extra_config_opt --config_opt --enable-nls=zh_CN " + shift 1 + ;; + --relocation) + extra_config_opt="$extra_config_opt --config_opt --enable-relocation " shift 1 ;; *) diff --git a/build/script/build_opengauss.sh b/build/script/build_opengauss.sh index ad33de8ef..7f6fb18a7 100755 --- a/build/script/build_opengauss.sh +++ b/build/script/build_opengauss.sh @@ -109,7 +109,7 @@ while [ $# -gt 0 ]; do echo "no extra configure options provided" exit 1 fi - extra_cmake_opt=$2 + extra_cmake_opt=" $2 $extra_cmake_opt " shift 2 ;; --config_opt) @@ -117,7 +117,7 @@ while [ $# -gt 0 ]; do echo "no extra configure options provided" exit 1 fi - extra_config_opt=$2 + extra_config_opt=" $2 $extra_config_opt " shift 2 ;; -T|--tassl) diff --git a/build/script/cmake_package_mini.sh b/build/script/cmake_package_mini.sh index 8c8e2e449..a1b83182e 100644 --- a/build/script/cmake_package_mini.sh +++ b/build/script/cmake_package_mini.sh @@ -809,5 +809,6 @@ echo "[makemppdb] $(date +%y-%m-%d' '%T): remove ${BUILD_DIR}" >>"$LOG_FILE" 2>& mkdir ${ROOT_DIR}/output mv ${ROOT_DIR}/build/script/*.tar.gz ${ROOT_DIR}/output/ +test -e ${ROOT_DIR}/build/script/gaussdb.map && mv ${ROOT_DIR}/build/script/gaussdb.map ${ROOT_DIR}/output/ echo "now, all packages has finished!" exit 0 \ No newline at end of file diff --git a/build/script/separate_debug_information.sh b/build/script/separate_debug_information.sh index 3d15ad910..54be94a7d 100644 --- a/build/script/separate_debug_information.sh +++ b/build/script/separate_debug_information.sh @@ -104,7 +104,7 @@ separate_symbol() ;; esac if [ -x "$x" ]; then - if [ "$x" != "install-sh" ]; then + if [ "$x" != "install-sh" ] && [ "$x" != "gaussdb.map" ]; then objcopy --only-keep-debug "$x" "$INSTALL_DIR/${symbol_name}.symbol" > /dev/null 2>&1 objcopy --strip-all "$x" "$x"_release rm "$x" @@ -191,3 +191,4 @@ cd $SYMBOLS_DIR/../ tar -zcf $PACKAGE_DIR/symbols.tar.gz symbols chmod 755 $PACKAGE_DIR/symbols.tar.gz cp $PACKAGE_DIR/symbols.tar.gz $DEPTH +mv "$BIN_DIR/gaussdb.map" $DEPTH diff --git a/build/script/utils/internal_packages.sh b/build/script/utils/internal_packages.sh index f33ab4198..a920d15cb 100644 --- a/build/script/utils/internal_packages.sh +++ b/build/script/utils/internal_packages.sh @@ -181,6 +181,12 @@ function make_package_upgrade_sql() echo "Successfully packaged upgrade_sql files." } +function move_gaussdb_map() +{ + cd $SCRIPT_DIR + deploy_pkgs gaussdb.map +} + function make_package_libpq() { cd $SCRIPT_DIR @@ -236,5 +242,6 @@ function gaussdb_pkg() make_package_libpq make_package_tools make_package_upgrade_sql + move_gaussdb_map echo "End package opengauss." } diff --git a/configure b/configure index 8f8621c02..726648bd9 100755 --- a/configure +++ b/configure @@ -754,6 +754,7 @@ enable_jemalloc_debug enable_privategauss enable_multiple_nodes enable_lite_mode +enable_relocation enable_finance_mode enable_mot enable_bbox @@ -842,6 +843,7 @@ enable_jemalloc_debug enable_privategauss enable_multiple_nodes enable_lite_mode +enable_relocation enable_finance_mode enable_mot enable_bbox @@ -3234,7 +3236,21 @@ $as_echo "$as_me: error: no argument expected for --enable-finance-mode option" else enable_finance_mode=no +fi + +# Check whether --enable-relocation was given. +if test "$enable_relocation" = yes; then + major_version=$(echo "$gcc_version" | cut -d'.' -f1) + minor_version=$(echo "$gcc_version" | cut -d'.' -f2) + if (( major_version < 10 )) || (( major_version >= 10 && minor_version < 3 )); then + { { $as_echo "$as_me:$LINENO: error: --enable-relocation is not supported where GCC compiler version is less than 10.3." >&5 + $as_echo "$as_me: error: -enable-relocation is not supported where GCC compiler version is less than 10.3." >&2;} + { (exit 1); exit 1; }; } + fi + enable_relocation=yes +else + enable_relocation=no fi if test "$enable_lite_nodes" = yes; then diff --git a/src/Makefile.global.in b/src/Makefile.global.in index daeda4438..e258b7d43 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -174,6 +174,7 @@ enable_jemalloc_debug = @enable_jemalloc_debug@ enable_privategauss = @enable_privategauss@ enable_multiple_nodes = @enable_multiple_nodes@ enable_lite_mode = @enable_lite_mode@ +enable_relocation = @enable_relocation@ enable_finance_mode = @enable_finance_mode@ enable_mot = @enable_mot@ enable_bbox = @enable_bbox@ diff --git a/src/gausskernel/CMakeLists.txt b/src/gausskernel/CMakeLists.txt index 10a9fb118..0d1aefda1 100755 --- a/src/gausskernel/CMakeLists.txt +++ b/src/gausskernel/CMakeLists.txt @@ -396,6 +396,9 @@ if(NOT "${ENABLE_UT}" STREQUAL "ON") add_executable(gaussdb ${gaussdb_objects}) target_link_options(gaussdb PRIVATE ${gaussdb_LINK_OPTIONS}) +if("${ENABLE_RELOCATION}" STREQUAL "ON") + target_link_options(gaussdb PRIVATE ${gaussdb_LINK_OPTIONS} "LINKER:-q") +endif() target_link_directories(gaussdb PRIVATE ${gaussdb_LINK_DIRS}) target_link_libraries(gaussdb PRIVATE ${gaussdb_LINK_LIBS}) add_dependencies(gaussdb ${gaussdb_DEPEND_LIST}) @@ -409,7 +412,10 @@ if(NOT "${ENABLE_UT}" STREQUAL "ON") endif() install(TARGETS gaussdb RUNTIME DESTINATION bin) -if(NOT "${ENABLE_LITE_MODE}" STREQUAL "ON") +if("${ENABLE_RELOCATION}" STREQUAL "ON") + install(CODE "execute_process(COMMAND cp gaussdb gaussdb.map WORKING_DIRECTORY \$ENV\{DESTDIR\}${CMAKE_INSTALL_PREFIX}/bin)") +endif() + if(NOT "${ENABLE_LITE_MODE}" STREQUAL "ON") install(CODE "execute_process(COMMAND ln -sf gaussdb gs_encrypt WORKING_DIRECTORY \$ENV\{DESTDIR\}${CMAKE_INSTALL_PREFIX}/bin)") install(CODE "message(\"-- Created symlink: gs_encrypt -> gaussdb\")") endif() diff --git a/src/gausskernel/Makefile b/src/gausskernel/Makefile index b8d6a87b1..ac5791f43 100755 --- a/src/gausskernel/Makefile +++ b/src/gausskernel/Makefile @@ -305,6 +305,9 @@ ifneq ($(PORTNAME), aix) gaussdb: $(OBJS) | $(CC) $(CXXFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $(export_dynamic) $(call expand_subsys,$^) $(LIBS) $(LLVMLIBS) $(HOTPATCH_ATOMIC_LDS) -o $@ +ifeq ($(enable_relocation), yes) + $(CC) $(CXXFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $(export_dynamic) $(call expand_subsys,$^) $(LIBS) $(LLVMLIBS) $(HOTPATCH_ATOMIC_LDS) -o $@.map -Wl,-q +endif $(CRC_CHECK) db: $(OBJS) @@ -705,6 +708,10 @@ endif install-bin: gaussdb $(POSTGRES_IMP) installdirs libcgroup $(INSTALL_PROGRAM) gaussdb$(X) '$(DESTDIR)$(bindir)/gaussdb$(X)' $(INSTALL_PROGRAM) '$(LZ4_BIN_PATH)/lz4' '$(DESTDIR)$(bindir)/lz4' +ifeq ($(enable_relocation), yes) + $(INSTALL_PROGRAM) gaussdb$(X).map '$(DESTDIR)$(bindir)/gaussdb$(X).map' +endif + ifeq ($(enable_lite_mode), no) @if test -d $(KERBEROS_BIN_PATH); then cp -rf $(KERBEROS_BIN_PATH)/klist $(DESTDIR)$(bindir)/; fi @if test -d $(KERBEROS_BIN_PATH); then cp -rf $(KERBEROS_BIN_PATH)/kinit $(DESTDIR)$(bindir)/; fi