提交 3f3f4a57 编写于 作者: C Chris Hajas

Fix configure and cmake to build ORCA with debug

Previously, we used a config file that was modified by cmake. Instead,
use configure to modify macros. Additionally use a compile definition in
cmake so we don't need a separate config file in gpos.

This also enables compile-time warnings in the src/backend/gporca files. C++ files
in the translator never had these warnings enabled, and so are not
enabled in src/backend/gpopt. A block of unused code is removed to get
pass the compile warnings.
上级 4c2ee984
......@@ -5844,12 +5844,20 @@ CFLAGS_VECTOR=$CFLAGS_VECTOR
# supply -g if --enable-debug
if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then
if test "$GCC" = yes; then
CFLAGS="$CFLAGS -g -ggdb"
CFLAGS="$CFLAGS -g -ggdb"
else
CFLAGS="$CFLAGS -g"
fi
fi
if test "$enable_debug" = yes && test "$ac_cv_prog_cxx_g" = yes; then
if test "$GCC" = yes; then
CXXFLAGS="$CXXFLAGS -g3 -ggdb"
else
CXXFLAGS="$CXXFLAGS -g3"
fi
fi
# enable code coverage if --enable-coverage
if test "$enable_coverage" = yes; then
if test "$GCC" = yes; then
......@@ -6271,6 +6279,19 @@ fi
$as_echo "checking whether to build with ORCA... $enable_orca" >&6; }
# Build ORCA in debug if enable-cassert
if test "$enable_cassert" = yes; then
$as_echo "#define GPOS_DEBUG 1" >>confdefs.h
fi
if test "$PORTNAME" = darwin; then
$as_echo "#define GPOS_Darwin 1" >>confdefs.h
fi
#
# --enable-mapreduce enables GPMapreduce support
#
......
......@@ -676,12 +676,20 @@ AC_SUBST(CFLAGS_VECTOR, $CFLAGS_VECTOR)
# supply -g if --enable-debug
if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then
if test "$GCC" = yes; then
CFLAGS="$CFLAGS -g -ggdb"
CFLAGS="$CFLAGS -g -ggdb"
else
CFLAGS="$CFLAGS -g"
fi
fi
if test "$enable_debug" = yes && test "$ac_cv_prog_cxx_g" = yes; then
if test "$GCC" = yes; then
CXXFLAGS="$CXXFLAGS -g3 -ggdb"
else
CXXFLAGS="$CXXFLAGS -g3"
fi
fi
# enable code coverage if --enable-coverage
if test "$enable_coverage" = yes; then
if test "$GCC" = yes; then
......@@ -808,6 +816,17 @@ PGAC_ARG_BOOL(enable, orca, yes, [disable ORCA optimizer],
AC_MSG_RESULT([checking whether to build with ORCA... $enable_orca])
AC_SUBST(enable_orca)
# Build ORCA in debug if enable-cassert
if test "$enable_cassert" = yes; then
AC_DEFINE([GPOS_DEBUG], 1,
[Define to 1 to build ORCA in debug (GPOS_DEBUG=1)])
fi
if test "$PORTNAME" = darwin; then
AC_DEFINE([GPOS_Darwin], 1,
[Define to 1 to build ORCA for MacOS (GPOS_Darwin=1)])
fi
#
# --enable-mapreduce enables GPMapreduce support
#
......
......@@ -8,8 +8,11 @@
subdir = src/backend/gpopt
top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
override CPPFLAGS := -I$(top_builddir)/src/backend/gporca/libgpos/include $(CPPFLAGS)
override CPPFLAGS := -I$(top_builddir)/src/backend/gporca/libgpopt/include $(CPPFLAGS)
override CPPFLAGS := -I$(top_builddir)/src/backend/gporca/libnaucrates/include $(CPPFLAGS)
override CPPFLAGS := -I$(top_builddir)/src/backend/gporca/libgpdbcost/include $(CPPFLAGS)
include $(top_builddir)/src/backend/gporca/gporca.mk
SUBDIRS = config translate relcache utils
......
......@@ -69,11 +69,13 @@ endif()
# Turn on GPOS_DEBUG define for DEBUG builds.
cmake_policy(SET CMP0043 NEW)
STRING(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
if (CMAKE_BUILD_TYPE_LOWER STREQUAL "debug")
set(GPOS_DEBUG 1)
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DGPOS_DEBUG")
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
add_compile_options(-DGPOS_Darwin)
endif()
add_compile_options(-DUSE_CMAKE)
# Turn on platform-specific defines.
set(GPOS_${CMAKE_SYSTEM_NAME} 1)
set(GPOS_${CMAKE_SYSTEM_PROCESSOR} 1)
......@@ -81,12 +83,6 @@ set(GPOS_${CMAKE_SYSTEM_PROCESSOR} 1)
# Library dependencies for optimizer.
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
# POSIX threads.
find_package(Threads REQUIRED)
if (NOT CMAKE_USE_PTHREADS_INIT)
message(FATAL_ERROR "Found a threading library, but it is not pthreads.")
endif()
# Xerces.
find_package(Xerces REQUIRED)
include_directories(${XERCES_INCLUDE_DIRS})
......
# Copyright (c) 2015, Pivotal Software, Inc.
# CMake module to find compiler built-ins for atomic operations.
# Test for GCC-style builtins for fetch-add and compare-and-swap (clang and ICC
# also have these). C++11 and C11 do this in an elegant standardized way, but
# we can not be assured of a C++11 compiler.
include(CheckCXXSourceCompiles)
CHECK_CXX_SOURCE_COMPILES("
#include <stdint.h>
int main() {
uint32_t value = 0;
uint32_t increment = 10;
uint32_t prev = __sync_fetch_and_add(&value, increment);
return static_cast<int>(prev);
}
" GPOS_GCC_FETCH_ADD_32)
CHECK_CXX_SOURCE_COMPILES("
#include <stdint.h>
int main() {
uint64_t value = 0;
uint64_t increment = 10;
uint64_t prev = __sync_fetch_and_add(&value, increment);
return static_cast<int>(prev);
}
" GPOS_GCC_FETCH_ADD_64)
CHECK_CXX_SOURCE_COMPILES("
#include <stdint.h>
int main() {
uint32_t value = 0;
uint32_t expected_value = 0;
uint32_t new_value = 10;
bool success = __sync_bool_compare_and_swap(&value, expected_value, new_value);
return success ? 0 : 1;
}
" GPOS_GCC_CAS_32)
CHECK_CXX_SOURCE_COMPILES("
#include <stdint.h>
int main() {
uint64_t value = 0;
uint64_t expected_value = 0;
uint64_t new_value = 10;
bool success = __sync_bool_compare_and_swap(&value, expected_value, new_value);
return success ? 0 : 1;
}
" GPOS_GCC_CAS_64)
......@@ -2,3 +2,7 @@ override CPPFLAGS := -I$(top_builddir)/src/backend/gporca/libgpos/include $(CPPF
override CPPFLAGS := -I$(top_builddir)/src/backend/gporca/libgpopt/include $(CPPFLAGS)
override CPPFLAGS := -I$(top_builddir)/src/backend/gporca/libnaucrates/include $(CPPFLAGS)
override CPPFLAGS := -I$(top_builddir)/src/backend/gporca/libgpdbcost/include $(CPPFLAGS)
# Do not omit frame pointer. Even with RELEASE builds, it is used for
# backtracing.
override CPPFLAGS := -Werror -Wextra -Wpedantic -Wno-variadic-macros -fno-omit-frame-pointer $(CPPFLAGS)
override CPPFLAGS := -std=gnu++98 $(CPPFLAGS)
......@@ -15,7 +15,7 @@ list(APPEND srcs ${hdrs})
add_library(gpdbcost ${srcs})
target_link_libraries(gpdbcost
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}
${CMAKE_DL_LIBS}
gpos
${XERCES_LIBRARIES})
......
......@@ -19,6 +19,6 @@ add_library(gpopt ${srcs})
target_link_libraries(gpopt
gpdbcost
naucrates
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}
${CMAKE_DL_LIBS}
gpos
${XERCES_LIBRARIES})
......@@ -27,36 +27,6 @@
using namespace gpopt;
//---------------------------------------------------------------------------
// @function:
// ICmpEdgesByLength
//
// @doc:
// Comparison function for simple join ordering: sort edges by length
// only to guaranteed that single-table predicates don't end up above
// joins;
//
//---------------------------------------------------------------------------
INT ICmpEdgesByLength
(
const void *pvOne,
const void *pvTwo
)
{
CJoinOrder::SEdge *pedgeOne = *(CJoinOrder::SEdge**)pvOne;
CJoinOrder::SEdge *pedgeTwo = *(CJoinOrder::SEdge**)pvTwo;
INT iDiff = (pedgeOne->m_pbs->Size() - pedgeTwo->m_pbs->Size());
if (0 == iDiff)
{
return (INT)pedgeOne->m_pbs->HashValue() - (INT)pedgeTwo->m_pbs->HashValue();
}
return iDiff;
}
// ctor
CJoinOrder::SComponent::SComponent
(
......
# Need pthreads.
find_package(Threads REQUIRED)
if (NOT CMAKE_USE_PTHREADS_INIT)
message(FATAL_ERROR "Found a threading library, but it is not pthreads.")
endif()
# Try to find atomic operations.
include(FindAtomics)
if ((NOT (GPOS_GCC_FETCH_ADD_32 AND GPOS_GCC_FETCH_ADD_64
AND GPOS_GCC_CAS_32 AND GPOS_GCC_CAS_64))
AND (NOT (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")))
message(FATAL_ERROR "Could not find GCC-style atomic built-ins or Solaris "
"atomic headers. GPOS will fail to build. Please try "
"using a recent g++ or clang++ compiler.")
endif()
include_directories(include)
include_directories(${PROJECT_SOURCE_DIR}/libgpopt/include/)
include_directories(${PROJECT_SOURCE_DIR}/libnaucrates/include/)
configure_file(config.h.in
${PROJECT_BINARY_DIR}/libgpos/include/gpos/config.h)
# for the generated config.h file.
include_directories(${PROJECT_BINARY_DIR}/libgpos/include/)
file(GLOB_RECURSE hdrs ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h)
file(GLOB_RECURSE srcs ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
......@@ -34,7 +11,7 @@ list(APPEND srcs ${hdrs})
add_library(gpos ${srcs})
target_link_libraries(gpos ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})
target_link_libraries(gpos ${CMAKE_DL_LIBS})
# Tests reside in the 'server' subdirectory.
add_subdirectory(server)
......@@ -17,7 +17,9 @@
#ifndef GPOS_api_H
#define GPOS_api_H
#include "gpos/config.h"
#ifndef USE_CMAKE
#include "pg_config.h"
#endif
#include "gpos/base.h"
#ifdef __cplusplus
......
......@@ -22,7 +22,10 @@
#ifndef GPOS_assert_H
#define GPOS_assert_H
#include "gpos/config.h"
#ifndef USE_CMAKE
#include "pg_config.h"
#endif
// retail assert; available in all builds
#define GPOS_RTL_ASSERT(x) ((x) ? ((void)0) : \
......
//---------------------------------------------------------------------------
// Greenplum Database
// Copyright (C) 2016 Greenplum, Inc.
//
// @filename:
// config.h
//
// @doc:
// Various compile-time options that affect binary
// compatibility.
//
//---------------------------------------------------------------------------
#ifndef GPOS_config_H
#define GPOS_config_H
/* Get this working for now. */
/* Idealy we should generate this files just like pg_config.h is generated */
#ifdef USE_ASSERT_CHECKING
#define GPOS_DEBUG
#else
#undef GPOS_DEBUG
#endif
#define GPOS_Darwin
#endif // GPOS_config_H
// EOF
......@@ -8,7 +8,13 @@ subdir = src/backend/gporca/libgpos/src/common
top_builddir = ../../../../../..
include $(top_builddir)/src/Makefile.global
include $(top_builddir)/src/backend/gporca/gporca.mk
override CPPFLAGS := -I$(top_builddir)/src/backend/gporca/libgpos/include $(CPPFLAGS)
override CPPFLAGS := -I$(top_builddir)/src/backend/gporca/libgpopt/include $(CPPFLAGS)
override CPPFLAGS := -I$(top_builddir)/src/backend/gporca/libnaucrates/include $(CPPFLAGS)
override CPPFLAGS := -I$(top_builddir)/src/backend/gporca/libgpdbcost/include $(CPPFLAGS)
# FIXME: Would be better to include gporca.mk, but hitting a warning
override CPPFLAGS := -Wno-variadic-macros -fno-omit-frame-pointer $(CPPFLAGS)
override CPPFLAGS := -std=gnu++98 $(CPPFLAGS)
OBJS = CAutoTimer.o \
CBitSet.o \
......
......@@ -15,7 +15,7 @@ list(APPEND srcs ${hdrs})
add_library(naucrates ${srcs})
target_link_libraries(naucrates
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}
${CMAKE_DL_LIBS}
gpos
${XERCES_LIBRARIES})
......
......@@ -82,6 +82,12 @@
# define gettimeofday(a,b) gettimeofday(a)
#endif
/* Define to 1 to build ORCA in debug (GPOS_DEBUG=1) */
#undef GPOS_DEBUG
/* Define to 1 to build ORCA for MacOS (GPOS_Darwin=1) */
#undef GPOS_Darwin
/* Greenplum major version as a string */
#undef GP_MAJORVERSION
......@@ -276,15 +282,6 @@
/* Define to 1 if you have the `gettimeofday' function. */
#undef HAVE_GETTIMEOFDAY
/* Define to 1 if you have the <gpdbcost/CCostModelGPDB.h> header file. */
#undef HAVE_GPDBCOST_CCOSTMODELGPDB_H
/* Define to 1 if you have the <gpopt/init.h> header file. */
#undef HAVE_GPOPT_INIT_H
/* Define to 1 if you have the <gpos/_api.h> header file. */
#undef HAVE_GPOS__API_H
/* Define to 1 if you have the <gssapi/gssapi.h> header file. */
#undef HAVE_GSSAPI_GSSAPI_H
......@@ -351,15 +348,6 @@
/* Define to 1 if you have the `execinfo' library (-lexecinfo). */
#undef HAVE_LIBEXECINFO
/* Define to 1 if you have the `gpdbcost' library (-lgpdbcost). */
#undef HAVE_LIBGPDBCOST
/* Define to 1 if you have the `gpopt' library (-lgpopt). */
#undef HAVE_LIBGPOPT
/* Define to 1 if you have the `gpos' library (-lgpos). */
#undef HAVE_LIBGPOS
/* Define to 1 if you have the `ldap' library (-lldap). */
#undef HAVE_LIBLDAP
......@@ -369,9 +357,6 @@
/* Define to 1 if you have the `m' library (-lm). */
#undef HAVE_LIBM
/* Define to 1 if you have the `naucrates' library (-lnaucrates). */
#undef HAVE_LIBNAUCRATES
/* Define to 1 if you have the `numa' library (-lnuma). */
#undef HAVE_LIBNUMA
......@@ -441,9 +426,6 @@
/* Define to 1 if you have the `mkdtemp' function. */
#undef HAVE_MKDTEMP
/* Define to 1 if you have the <naucrates/init.h> header file. */
#undef HAVE_NAUCRATES_INIT_H
/* Define to 1 if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册