Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure pg_config --cppflags are passed #5786

Merged
merged 1 commit into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .unreleased/bugfix_5786
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes: #5786 Ensure pg_config --cppflags are passed
3 changes: 1 addition & 2 deletions src/build-defs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ if(UNIX)
set(CMAKE_C_STANDARD 11)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${PG_LIBDIR}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -L${PG_LIBDIR}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PG_CFLAGS}")
set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} ${PG_CPPFLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PG_CFLAGS} ${PG_CPPFLAGS}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are you building that needs C++ flags? TimescaleDB itself doesn't use them IIRC. Postgres only uses them for the JIT engine if you configure it with --with-llvm

This line in particular doesn't look correct, you can't generally put the C++ flags into the C ones.

Copy link
Contributor Author

@sumerman sumerman Jun 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pg_config passes include paths in the CPPFLAGS. On my system it looks like this:

-I/opt/homebrew/Cellar/icu4c/72.1/include -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/opt/openssl@1.1/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/Cellar/lz4/1.9.4/include

while OpenSSL and MacOSX13.sdk are correctly discovered in by CMake, it knows nothing about icu4c and gettext leading to #2777

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized that CPPFLAGS are C preprocessor flags, not C++ flags. CMake doesn't have support for them, so it's OK to just paste them with the rest of the C flags. So this line looks correct.

set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
endif()

Expand Down
3 changes: 1 addition & 2 deletions tsl/src/build-defs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ if(UNIX)
set(CMAKE_C_STANDARD 11)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${PG_LIBDIR}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -L${PG_LIBDIR}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PG_CFLAGS}")
set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} ${PG_CPPFLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PG_CFLAGS} ${PG_CPPFLAGS}")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
endif()

Expand Down