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

build(c): force C++11 for drivers for R's sake #844

Merged
merged 4 commits into from
Jun 24, 2023

Conversation

lidavidm
Copy link
Member

Fixes #815.
Fixes #842.

@lidavidm
Copy link
Member Author

The build isn't -Wextra clean right now, sadly.

@lidavidm lidavidm requested review from kou and paleolimbot June 23, 2023 19:21
@lidavidm
Copy link
Member Author

Ugh, some of the utility code needs to be fixed, moving to draft

@lidavidm lidavidm marked this pull request as draft June 23, 2023 20:58
adbc_configure_target(${LIB_NAME}_objlib)
# https://github.com/apache/arrow-adbc/issues/81
target_compile_features(${LIB_NAME}_objlib PRIVATE cxx_std_11)
set_property(TARGET ${LIB_NAME}_objlib PROPERTY CXX_STANDARD 11)
Copy link
Member

Choose a reason for hiding this comment

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

This may be redundant. (I think that we only need target_compile_features().)

-Wpedantic
-Wno-unused-parameter
-Wunused-result)
if(NOT ADBC_BUILD_WARNING_LEVEL OR ADBC_BUILD_WARNING_LEVEL STREQUAL "")
Copy link
Member

Choose a reason for hiding this comment

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

Can we simplify this?

Suggested change
if(NOT ADBC_BUILD_WARNING_LEVEL OR ADBC_BUILD_WARNING_LEVEL STREQUAL "")
if("${ADBC_BUILD_WARNING_LEVEL}" STREQUAL "")

endif()
elseif("${ADBC_BUILD_WARNING_LEVEL}" STREQUAL "PRODUCTION")
if(MSVC)
set(CMAKE_C_FLAGS /Wall)
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this?

else()
message(WARNING "Unknown compiler: ${CMAKE_CXX_COMPILER_ID}")
endif()
endif()
Copy link
Member

Choose a reason for hiding this comment

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

We may want to use the following style:

if(MSVC)
  set(ADBC_C_CXX_FLAGS_CHECKIN "/Wall /WX")
  set(ADBC_C_CXX_FLAGS_PRODUCTION "/Wall /WX")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" ...)
  set(ADBC_C_CXX_FLAGS_CHECKIN "...")
  set(ADBC_C_CXX_FLAGS_PRODUCTION "...")
else()
  ...
endif()

target_compile_options(${TARGET} PRIVATE ${ADBC_C_CXX_FLAGS_${ADBC_BUILD_WARNING_LEVEL}})

@WillAyd
Copy link
Contributor

WillAyd commented Jun 23, 2023

Guess all the utils stuff is complaining about NanoArrow's GetInt method returning a 64 bit integer, while some of the fields we are assigning to are 16/32. I can add some more safety checks there in a separate PR if it helps

set(ADBC_C_CXX_FLAGS)
if("${ADBC_BUILD_WARNING_LEVEL}" STREQUAL "CHECKIN")
if(MSVC)
set(ADBC_C_CXX_FLAGS /Wall /WX)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a Windows expert by any means but wondering if we should start with a lower warning level like W2, W3, or W4 instead of Wall?

Copy link
Contributor

Choose a reason for hiding this comment

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

Most of the warnings are coming from the vendored nanoarrow which doesn't build with warnings on MSVC. A lot of the case statement warnings are easy enough to fix but will be hard to warn on MSVC downstream if also not set up in nanoarrow

Copy link
Member

Choose a reason for hiding this comment

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

I fixed a number of them here: apache/arrow-nanoarrow#191 (it looks like vendored nanoarrow predates that?)

@lidavidm
Copy link
Member Author

Thanks Kou!

Will: I'd like to have /Wall if possible, but given the flood of warnings from Nanoarrow, that may not be possible...and as I recall, MSVC didn't support the equivalent of -isystem until very recently.

@WillAyd
Copy link
Contributor

WillAyd commented Jun 23, 2023

Yea makes sense. If this PR isn't a rush I don't think it's unreasonable to get Wall to work for MSVC

@lidavidm
Copy link
Member Author

I'm somewhat inclined to skip MSVC for now just so that we enforce C++11 for R, and get MSVC fixed separately since it looks like it'll be a giant pain.

@lidavidm
Copy link
Member Author

Hmm, that appears to have fixed things in CI (what I expect is that the next person to try to do development on MSVC is going to get a giant wall of warnings)

@lidavidm lidavidm marked this pull request as ready for review June 23, 2023 23:01
Copy link
Member

@paleolimbot paleolimbot left a comment

Choose a reason for hiding this comment

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

I can't speak to the CMake...the R packages don't use CMake or MSVC and it seems like that might be forcing some complexity that could be avoided

Perhaps instead of forcing C++11 in CMake we could just add a line - {os: windows-latest, r: '3.6', pkg: 'adbcpostgresql'} right here: https://github.com/apache/arrow-adbc/blob/main/.github/workflows/native-unix.yml#L596C11-L596C72 . I think checking that it builds is sufficient for CI...I can run tests from R with a Docker setup locally before submitting to CRAN. I'm happy to make that CI change in another PR.

For Centos7 I ran:

# docker run --rm -it -v $(pwd):/arrow-adbc ghcr.io/apache/arrow-nanoarrow:centos7-arm64
cd /arrow-adbc
yum install postgresql-devel
R -e 'install.packages("nanoarrow", repos = "https://cloud.r-project.org")'
R CMD INSTALL r/adbcdrivermanager --preclean
R CMD INSTALL r/adbcpostgresql --preclean

...with no problems.

I did run into a slight problem on R 3.6/Windows because NODATA is apparently not defined. Defining it to 148 in postgres_copy_reader.h if not previously defined seemed to do the trick. (Again, I'm happy to do that in another PR).

@lidavidm
Copy link
Member Author

An R 3.6 pipeline would be useful in combination with this, just to verify that it actually works. But I'd like to have the CMake config so that we get immediate feedback for local development.

@lidavidm lidavidm merged commit 518f21d into apache:main Jun 24, 2023
@lidavidm lidavidm deleted the gh-842-cpp17 branch June 24, 2023 16:27
@lidavidm
Copy link
Member Author

I filed #848

lidavidm pushed a commit that referenced this pull request Jun 25, 2023
It seems like an older version may be causing problems with MSVC
warnings (#847,
#844 (comment) ).
@lidavidm lidavidm added this to the ADBC Libraries 0.6.0 milestone Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants