ARROW-15709: [C++] Compilation of ARROW_ENGINE fails if doing an "inline" build - #12457

Closed
jvanstraten wants to merge 11 commits into
apache:masterfrom
jvanstraten:ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi
Closed

ARROW-15709: [C++] Compilation of ARROW_ENGINE fails if doing an "inline" build#12457
jvanstraten wants to merge 11 commits into
apache:masterfrom
jvanstraten:ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi

Conversation

@jvanstraten

@jvanstratenjvanstraten commented Feb 17, 2022

Copy link
Copy Markdown
Contributor

This should fix:


Initial attempt at making something functional to solve this issue properly.

The use of add_arrow_lib in ThirdpartyToolchain.cmake is certainly odd, and I'm sure I'm not following best practices in that file in general. I could use some advice on what the proper way to do this would be. Some of the issues:

  • The CMake property specifying that a path refers to a generated file is scoped only to the current CMake file, so only moving the externalproject_add over to ThirdpartyToolchain.cmake resulted in the add_arrow_lib in src/arrow/engine failing due to missing source files. An object library didn't seem to resolve it either, and there are probably portability issues with that anyway, so that's why I ended up just using add_arrow_lib.
  • Unlike all the other third-party dependencies (AFAICT), Substrait can't currently be installed, so Substrait_SOURCE=SYSTEM makes no sense. In the end I just decided to override it, but that's probably not ideal.
  • Substrait doesn't have releases yet, so I had to resort to a git hash instead.

@github-actions

Copy link
Copy Markdown

@westonpace

Copy link
Copy Markdown
Member

@kou@pitrou We could use input on this approach. The Substrait integration is a little unique because the .proto files themselves are not owned by us. We could fork a copy of the proto files but that would make keeping up with updated versions a bit tricky.

Protobuf is also a bit tricky because the version of the code generation tool (protoc) must match the version of the linked protobuf library exactly (this is different from flatbuffers which doesn't require a runtime dependency).

Previously we were downloading the proto files using git and running protoc within the engine directory. This had some negative side effects (#12454) mainly due to our use of git. Even beyond git however it was rather strange that this was resulting in a call to externalproject_add outside of ThirdPartyToolchain.cmake so @jvanstraten and I agreed it might be clear to treat Substrait as a "build-from-source only" third party dependency. This PR is @jvanstraten 's attempt to make that work but it is also odd as it requires a call to add_arrow_lib inside of ThirdPartyToolchain.cmake.

Any suggestions on a better approach or feedback on our current approach would be very much welcomed.

@jvanstraten
jvanstratenforce-pushed the ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi branch from a049bdd to fd6e5d4CompareFebruary 18, 2022 10:48
@kou

kou commented Feb 20, 2022

Copy link
Copy Markdown
Member

How about using just an OBJECT library https://cmake.org/cmake/help/latest/command/add_library.html#object-lib instead of arrow_add_lib()?

diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake
index 391c43e0ac..3afecfc562 100644
--- a/cpp/cmake_modules/BuildUtils.cmake+++ b/cpp/cmake_modules/BuildUtils.cmake@@ -297,6 +297,14 @@ function(ADD_ARROW_LIB LIB_NAME)
target_precompile_headers(${LIB_NAME}_objlib PRIVATE ${ARG_PRECOMPILED_HEADERS})
endif()
set(LIB_DEPS $<TARGET_OBJECTS:${LIB_NAME}_objlib>)
+ # We need to specify $<TARGET_OBJECTS:XXX> explicitly to SHARED+ # library and STATIC library because $<TARGET_OBJECTS:XXX> in+ # OBJECT isn't propagated to SHARED library and STATIC library.+ foreach(ARG_SOURCE ${ARG_SOURCES})+ if(ARG_SOURCE MATCHES "^\\$<TARGET_OBJECTS:")+ list(APPEND LIB_DEPS ${ARG_SOURCE})+ endif()+ endforeach()
set(LIB_INCLUDES)
set(EXTRA_DEPS)
diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index 8b53272452..9143550df9 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake@@ -1687,22 +1687,13 @@ macro(build_substrait)
add_custom_target(substrait_gen ALL DEPENDS ${SUBSTRAIT_PROTO_GEN_ALL})
- add_arrow_lib(arrow_substrait- SOURCES- ${SUBSTRAIT_SOURCES}- DEPENDENCIES- substrait_gen- SHARED_LINK_LIBS- ${ARROW_PROTOBUF_LIBPROTOBUF}- STATIC_LINK_LIBS- ${ARROW_PROTOBUF_LIBPROTOBUF}- PRIVATE_INCLUDES- ${SUBSTRAIT_CPP_DIR})-- set(SUBSTRAIT_DEPENDENCIES substrait_gen)- set(SUBSTRAIT_SHARED arrow_substrait_shared)- set(SUBSTRAIT_STATIC arrow_substrait_static)- set(SUBSTRAIT_INCLUDES ${SUBSTRAIT_CPP_DIR})+ add_library(substrait OBJECT ${SUBSTRAIT_SOURCES})+ set_target_properties(substrait+ PROPERTIES+ INCLUDE_DIRECTORIES ${SUBSTRAIT_CPP_DIR}+ POSITION_INDEPENDENT_CODE ON)+ add_dependencies(substrait substrait_gen)+ get_target_property(SUBSTRAIT_INCLUDES substrait INCLUDE_DIRECTORIES)
endmacro()
if(ARROW_WITH_SUBSTRAIT)
diff --git a/cpp/src/arrow/engine/CMakeLists.txt b/cpp/src/arrow/engine/CMakeLists.txt
index 50a84464c0..ff88f47e4a 100644
--- a/cpp/src/arrow/engine/CMakeLists.txt+++ b/cpp/src/arrow/engine/CMakeLists.txt@@ -36,9 +36,10 @@ add_arrow_lib(arrow_engine
OUTPUTS
ARROW_ENGINE_LIBRARIES
DEPENDENCIES
- ${SUBSTRAIT_DEPENDENCIES}+ substrait
SOURCES
${ARROW_ENGINE_SRCS}
+ $<TARGET_OBJECTS:substrait>
PRECOMPILED_HEADERS
"$<$<COMPILE_LANGUAGE:CXX>:arrow/engine/pch.h>"
SHARED_LINK_FLAGS
@@ -46,11 +47,9 @@ add_arrow_lib(arrow_engine
SHARED_LINK_LIBS
arrow_shared
arrow_dataset_shared
- ${SUBSTRAIT_SHARED}
STATIC_LINK_LIBS
arrow_static
arrow_dataset_static
- ${SUBSTRAIT_STATIC}
PRIVATE_INCLUDES
${SUBSTRAIT_INCLUDES})

@jvanstraten

Copy link
Copy Markdown
ContributorAuthor

@kou Thanks for the input! It's certainly a lot nicer to do it that way, but unfortunately, we're not quite there yet... I got it working in most build environments using your diff with some minor changes (had to add protobuf to the include list for the object library, and add its runtime library to arrow_engine), but it fails here:

CMake Error at cmake_modules/BuildUtils.cmake:287 (add_library):
OBJECT library "arrow_engine_objlib" contains:
capabilities.pb.cc.o
expression.pb.cc.o
extensions.pb.cc.o
function.pb.cc.o
parameterized_types.pb.cc.o
plan.pb.cc.o
relations.pb.cc.o
type.pb.cc.o
type_expressions.pb.cc.o
but may contain only sources that compile, header files, and other files
that would not affect linking of a normal library.

I feel like the addition to BuildUtils.cmake is either causing this or supposed to resolve this (and failing to do so in this particular case), but other than that, my skill level for CMake is insufficient to see what exactly is going on here.

set(SUBSTRAIT_SOURCE_URL "$ENV{ARROW_SUBSTRAIT_URL}")
else()
set_urls(SUBSTRAIT_SOURCE_URL
"https://github.com/substrait-io/substrait/archive/${ARROW_SUBSTRAIT_BUILD_VERSION}.tar.gz"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1, this will be much better than involving some git commands.

Comment threadcpp/src/arrow/engine/CMakeLists.txt Outdated
substrait
SOURCES
${ARROW_ENGINE_SRCS}
$<TARGET_OBJECTS:substrait>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm... is there a particular reason for this? Should we instead create a static library containing these objects? Or perhaps I'm entirely misunderstanding this?

@koukouFeb 21, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can use a static library instead of an object library without using add_arrow_lib(). We can just use raw add_library().

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Looks like that's working, 577979b. I wasn't sure how generally-applicable linking static libraries with -fPIC into shared libraries would be. I'm also not sure why I still need to specify PRIVATE_INCLUDES ${SUBSTRAIT_INCLUDES} for the add_arrow_lib call (shouldn't CMake be propagating public include directories to dependent libraries?), but I couldn't get it to work without it.

@jvanstraten
jvanstraten marked this pull request as ready for review February 22, 2022 18:27
# under the License.

# Currently, we can only build Substrait from source.
set(SUBSTRAIT_FOUND NO)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we remove this file?
It seems that this file is never used.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Comment threadcpp/src/arrow/engine/CMakeLists.txt Outdated
Comment on lines +38 to +39
DEPENDENCIES
substrait

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we remove this?
This will be automatically added by using substrait target.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

It doesn't build (multithreaded) without it. I think it ensures that substrait is built completely prior to compilation of arrow_engine, rather than just prior to linking, which matters because arrow_engine uses generated code. Making it depend on substrait_gen would also work, if you prefer that option (IMO, the less arrow_engine depends on implementation details of ThirdpartyToolchain.cmake the better, so I set it to just substrait).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems that this is a problem of our add_arrow_lib():

diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake
index 391c43e0ac..7517e4e806 100644
--- a/cpp/cmake_modules/BuildUtils.cmake+++ b/cpp/cmake_modules/BuildUtils.cmake@@ -374,6 +374,13 @@ function(ADD_ARROW_LIB LIB_NAME)
"$<INSTALL_INTERFACE:${ARG_SHARED_INSTALL_INTERFACE_LIBS}>"
LINK_PRIVATE
${ARG_SHARED_PRIVATE_LINK_LIBS})
+ if(USE_OBJLIB)+ foreach(ARG_SHARED_LINK_LIB ${ARG_SHARED_LINK_LIBS})+ if(TARGET ${ARG_SHARED_LINK_LIB})+ add_dependencies(${LIB_NAME}_objlib ${ARG_SHARED_LINK_LIB})+ endif()+ endforeach()+ endif()
if(ARROW_RPATH_ORIGIN)
if(APPLE)
@@ -449,6 +456,13 @@ function(ADD_ARROW_LIB LIB_NAME)
if(ARG_STATIC_LINK_LIBS)
target_link_libraries(${LIB_NAME}_static LINK_PRIVATE
"$<BUILD_INTERFACE:${ARG_STATIC_LINK_LIBS}>")
+ if(USE_OBJLIB)+ foreach(ARG_STATIC_LINK_LIB ${ARG_STATIC_LINK_LIBS})+ if(TARGET ${ARG_STATIC_LINK_LIB})+ add_dependencies(${LIB_NAME}_objlib ${ARG_STATIC_LINK_LIB})+ endif()+ endforeach()+ endif()
endif()
install(TARGETS ${LIB_NAME}_static ${INSTALL_IS_OPTIONAL}
diff --git a/cpp/src/arrow/engine/CMakeLists.txt b/cpp/src/arrow/engine/CMakeLists.txt
index 13d50b4244..edb878939f 100644
--- a/cpp/src/arrow/engine/CMakeLists.txt+++ b/cpp/src/arrow/engine/CMakeLists.txt@@ -35,8 +35,6 @@ add_arrow_lib(arrow_engine
arrow-engine
OUTPUTS
ARROW_ENGINE_LIBRARIES
- DEPENDENCIES- substrait
SOURCES
${ARROW_ENGINE_SRCS}
PRECOMPILED_HEADERS

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Okay, that fixes it on my end, too. fffa65c

set_target_properties(substrait PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(substrait PUBLIC ${SUBSTRAIT_INCLUDES})
target_link_libraries(substrait INTERFACE ${ARROW_PROTOBUF_LIBPROTOBUF})
add_dependencies(substrait substrait_gen)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you add substrait to ARROW_BUNDLED_STATIC_LIBS?

Suggested change
add_dependencies(substraitsubstrait_gen)
list(APPEND ARROW_BUNDLED_STATIC_LIBS substrait)

If we don't add this, users can't link to libarrow_engine.a statically with libarrow_bundled_dependencies.a.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Added in 3d7bac9

The removal of add_dependencies(substrait substrait_gen) seems unrelated. I suppose it's technically redundant, since CMake will generate the .cc files by way of needing them as input for compiling substrait, and the .h files just so happen to be generated by the same command. If for whatever reason only the generated .h files are removed though, CMake won't know to recreate them without that rule.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, sorry. It's my fault.

@jvanstraten

Copy link
Copy Markdown
ContributorAuthor

Failure of AMD64 Ubuntu 20.04 GLib & Ruby for
fffa65c seems to be unrelated (zlib download failure, I think). It builds correctly when I run it with archery locally.

@kou

kou commented Feb 23, 2022

Copy link
Copy Markdown
Member

@github-actions crossbow submit python-sdist

@github-actions

Copy link
Copy Markdown

Revision: fffa65c

Submitted crossbow builds: ursacomputing/crossbow @ actions-1676

TaskStatus
python-sdistGithub Actions

@jvanstraten

Copy link
Copy Markdown
ContributorAuthor

@kou@pitrou@westonpace I believe this is ready to be merged, or am I still missing something?

LINK_PRIVATE
${ARG_SHARED_PRIVATE_LINK_LIBS})

if(USE_OBJLIB)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add a comment explaining this snippet?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Added something in c2380ee. @kou, please verify if what I wrote for it is correct and complete.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Right.

Comment threadcpp/cmake_modules/BuildUtils.cmake Outdated
${ARG_SHARED_PRIVATE_LINK_LIBS})

if(USE_OBJLIB)
foreach(ARG_SHARED_LINK_LIB ${ARG_SHARED_LINK_LIBS})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor, but naming ARG_SOMETHING a variable that is not one of the original function arguments is confusing.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Comment on lines +1677 to +1681
add_custom_command(OUTPUT "${SUBSTRAIT_PROTO_GEN}.${EXT}"
COMMAND ${ARROW_PROTOBUF_PROTOC} "-I${SUBSTRAIT_LOCAL_DIR}/proto"
"--cpp_out=${SUBSTRAIT_CPP_DIR}"
"${SUBSTRAIT_LOCAL_DIR}/proto/substrait/${SUBSTRAIT_PROTO}.proto"
DEPENDS ${PROTO_DEPENDS} substrait_ep)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems like it compiles each proto file twice (once per extension)? Is that desired?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

No, probably not. I noticed it too when I inherited this code, but incorrectly assumed it was written like that because add_custom_command only supported a single output file. 7ad2e1f

@pitrou

Copy link
Copy Markdown
Member

Perhaps @kou can also double-check the CMake changes.

@westonpacewestonpace left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have nothing further to add. I think this looks much nicer than what we had before. We might try and take some snippets from here and push them upstream into the Substrait project's documentation in some kind of "getting started with C++" section.

kou
kou approved these changes Feb 25, 2022

@koukou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1

LINK_PRIVATE
${ARG_SHARED_PRIVATE_LINK_LIBS})

if(USE_OBJLIB)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Right.

@koukou closed this in 89cc6b3Feb 25, 2022
@ursabot

ursabot commented Feb 25, 2022

Copy link
Copy Markdown

Benchmark runs are scheduled for baseline = acfd1d2 and contender = 89cc6b3. 89cc6b3 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Finished ⬇️0.21% ⬆️0.0%] test-mac-arm
[Finished ⬇️0.71% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️0.3% ⬆️0.0%] ursa-thinkcentre-m75q
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

marin-ma pushed a commit to marin-ma/arrow-1 that referenced this pull request Mar 28, 2022
…ine" build
This should fix:
- inline builds in general (ARROW-15709);
- [weird stuff with inline builds causing non-tracked files to be deleted](https://github.com/apache/arrow;/pull/12444#issuecomment-1043143303) that the [previous fix](apache#12444) for the above [caused](apache#12454)
- dependencies on git for downloading dependencies (ARROW-15760);
- the build process for Substrait previously being treated as something too special to use Arrow's normal method for dealing with third-party dependencies (i.e. `ThirdpartyToolchain.cmake`)
---
Initial attempt at making something functional to solve this issue properly.
The use of `add_arrow_lib` in `ThirdpartyToolchain.cmake` is certainly odd, and I'm sure I'm not following best practices in that file in general. I could use some advice on what the proper way to do this would be. Some of the issues:
- The CMake property specifying that a path refers to a generated file is scoped only to the current CMake file, so only moving the `externalproject_add` over to `ThirdpartyToolchain.cmake` resulted in the `add_arrow_lib` in `src/arrow/engine` failing due to missing source files. An object library didn't seem to resolve it either, and there are probably portability issues with that anyway, so that's why I ended up just using `add_arrow_lib`.
- Unlike all the other third-party dependencies (AFAICT), Substrait can't currently be installed, so `Substrait_SOURCE=SYSTEM` makes no sense. In the end I just decided to override it, but that's probably not ideal.
- Substrait doesn't have releases yet, so I had to resort to a git hash instead.
</details>
Closesapache#12457 from jvanstraten/ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi
Authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
(cherry picked from commit 89cc6b3)
zhouyuan pushed a commit to oap-project/arrow that referenced this pull request Apr 18, 2022
* ARROW-15238: [C++] ARROW_ENGINE module with substrait consumer
Continuation of apache#11707. I'm taking over from @bkietz for now because he's unavailable right now for personal reasons.
Closesapache#12279 from jvanstraten/substrait-consumer
Lead-authored-by: Benjamin Kietzman <bengilgit@gmail.com>
Co-authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Co-authored-by: Weston Pace <weston.pace@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
* ARROW-15700: [C++] Compilation error on Ubuntu 18.04
Modified Substrait consumer interaction with libprotobuf to support versions down to 3.0.0, which is the minimum required due to Substrait's usage of proto3 syntax.
Tested locally with:
```
export ARROW_PROTOBUF_URL=https://github.com/protocolbuffers/protobuf/releases/download/v3.0.0/protobuf-cpp-3.0.0.tar.gz
cmake \
--preset ninja-debug \
-DProtobuf_SOURCE=BUNDLED \
-DARROW_PROTOBUF_BUILD_VERSION=v3.0.0 \
-DARROW_PROTOBUF_BUILD_SHA256_CHECKSUM=318e8f375fb4e5333975a40e0d1215e855b4a8c581d692eb0eb7df70db1a8d4e
```
(Is there an easier way to do this without modifying versions.txt or 751fb9d? Also, the env var is needed only because Google isn't at all consistent with their release file naming that far back.)
It'd also be nice to add this to CI, but it's probably excessive to always run for a PR, unless combined with some other run.
Closesapache#12448 from jvanstraten/ARROW-15700-Compilation-error-on-Ubuntu-18-04
Authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
(cherry picked from commit 7d16a78)
* ARROW-15258: [C++] Easy options to create a source node from a table
This PR includes the addition of `TableSourceNode` to create a `ExecNode` easily using a table as the data source.
### TODO
- [x] Fix test case for chunk_size
Closesapache#12267 from vibhatha/arrow-15258-rb
Authored-by: Vibhatha Abeykoon <vibhatha@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
(cherry picked from commit fffdca2)
* ARROW-15709: [C++] Compilation of ARROW_ENGINE fails if doing an "inline" build
This should fix:
- inline builds in general (ARROW-15709);
- [weird stuff with inline builds causing non-tracked files to be deleted](https://github.com/apache/arrow;/pull/12444#issuecomment-1043143303) that the [previous fix](apache#12444) for the above [caused](apache#12454)
- dependencies on git for downloading dependencies (ARROW-15760);
- the build process for Substrait previously being treated as something too special to use Arrow's normal method for dealing with third-party dependencies (i.e. `ThirdpartyToolchain.cmake`)
---
Initial attempt at making something functional to solve this issue properly.
The use of `add_arrow_lib` in `ThirdpartyToolchain.cmake` is certainly odd, and I'm sure I'm not following best practices in that file in general. I could use some advice on what the proper way to do this would be. Some of the issues:
- The CMake property specifying that a path refers to a generated file is scoped only to the current CMake file, so only moving the `externalproject_add` over to `ThirdpartyToolchain.cmake` resulted in the `add_arrow_lib` in `src/arrow/engine` failing due to missing source files. An object library didn't seem to resolve it either, and there are probably portability issues with that anyway, so that's why I ended up just using `add_arrow_lib`.
- Unlike all the other third-party dependencies (AFAICT), Substrait can't currently be installed, so `Substrait_SOURCE=SYSTEM` makes no sense. In the end I just decided to override it, but that's probably not ideal.
- Substrait doesn't have releases yet, so I had to resort to a git hash instead.
</details>
Closesapache#12457 from jvanstraten/ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi
Authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
(cherry picked from commit 89cc6b3)
* ARROW-15830: [C++] Ensure target directory exists before running Substrait generation
Closesapache#12548 from pitrou/ARROW-15830-ubuntu-cpp-bundled
Authored-by: Antoine Pitrou <antoine@python.org>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
(cherry picked from commit e989fb3)
* ARROW-15850: [C++] Engine substrait headers missing from install
Closesapache#12569 from westonpace/feature/ARROW-15850--substrait-headers-missing
Authored-by: Weston Pace <weston.pace@gmail.com>
Signed-off-by: David Li <li.davidm96@gmail.com>
(cherry picked from commit 8fce593)
* Enable TPCH Q6 & Q1
Co-authored-by: Benjamin Kietzman <bengilgit@gmail.com>
Co-authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Co-authored-by: Weston Pace <weston.pace@gmail.com>
Co-authored-by: Vibhatha Abeykoon <vibhatha@gmail.com>
Co-authored-by: Antoine Pitrou <antoine@python.org>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@jvanstraten@westonpace@kou@pitrou@ursabot
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

ARROW-15709: [C++] Compilation of ARROW_ENGINE fails if doing an "inline" build - #12457

Closed
jvanstraten wants to merge 11 commits into
apache:masterfrom
jvanstraten:ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi
Closed

ARROW-15709: [C++] Compilation of ARROW_ENGINE fails if doing an "inline" build#12457
jvanstraten wants to merge 11 commits into
apache:masterfrom
jvanstraten:ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi

Conversation

@jvanstraten

@jvanstratenjvanstraten commented Feb 17, 2022

Copy link
Copy Markdown
Contributor

This should fix:


Initial attempt at making something functional to solve this issue properly.

The use of add_arrow_lib in ThirdpartyToolchain.cmake is certainly odd, and I'm sure I'm not following best practices in that file in general. I could use some advice on what the proper way to do this would be. Some of the issues:

  • The CMake property specifying that a path refers to a generated file is scoped only to the current CMake file, so only moving the externalproject_add over to ThirdpartyToolchain.cmake resulted in the add_arrow_lib in src/arrow/engine failing due to missing source files. An object library didn't seem to resolve it either, and there are probably portability issues with that anyway, so that's why I ended up just using add_arrow_lib.
  • Unlike all the other third-party dependencies (AFAICT), Substrait can't currently be installed, so Substrait_SOURCE=SYSTEM makes no sense. In the end I just decided to override it, but that's probably not ideal.
  • Substrait doesn't have releases yet, so I had to resort to a git hash instead.

@github-actions

Copy link
Copy Markdown

@westonpace

Copy link
Copy Markdown
Member

@kou@pitrou We could use input on this approach. The Substrait integration is a little unique because the .proto files themselves are not owned by us. We could fork a copy of the proto files but that would make keeping up with updated versions a bit tricky.

Protobuf is also a bit tricky because the version of the code generation tool (protoc) must match the version of the linked protobuf library exactly (this is different from flatbuffers which doesn't require a runtime dependency).

Previously we were downloading the proto files using git and running protoc within the engine directory. This had some negative side effects (#12454) mainly due to our use of git. Even beyond git however it was rather strange that this was resulting in a call to externalproject_add outside of ThirdPartyToolchain.cmake so @jvanstraten and I agreed it might be clear to treat Substrait as a "build-from-source only" third party dependency. This PR is @jvanstraten 's attempt to make that work but it is also odd as it requires a call to add_arrow_lib inside of ThirdPartyToolchain.cmake.

Any suggestions on a better approach or feedback on our current approach would be very much welcomed.

@jvanstraten
jvanstratenforce-pushed the ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi branch from a049bdd to fd6e5d4CompareFebruary 18, 2022 10:48
@kou

kou commented Feb 20, 2022

Copy link
Copy Markdown
Member

How about using just an OBJECT library https://cmake.org/cmake/help/latest/command/add_library.html#object-lib instead of arrow_add_lib()?

diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake
index 391c43e0ac..3afecfc562 100644
--- a/cpp/cmake_modules/BuildUtils.cmake+++ b/cpp/cmake_modules/BuildUtils.cmake@@ -297,6 +297,14 @@ function(ADD_ARROW_LIB LIB_NAME)
target_precompile_headers(${LIB_NAME}_objlib PRIVATE ${ARG_PRECOMPILED_HEADERS})
endif()
set(LIB_DEPS $<TARGET_OBJECTS:${LIB_NAME}_objlib>)
+ # We need to specify $<TARGET_OBJECTS:XXX> explicitly to SHARED+ # library and STATIC library because $<TARGET_OBJECTS:XXX> in+ # OBJECT isn't propagated to SHARED library and STATIC library.+ foreach(ARG_SOURCE ${ARG_SOURCES})+ if(ARG_SOURCE MATCHES "^\\$<TARGET_OBJECTS:")+ list(APPEND LIB_DEPS ${ARG_SOURCE})+ endif()+ endforeach()
set(LIB_INCLUDES)
set(EXTRA_DEPS)
diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index 8b53272452..9143550df9 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake@@ -1687,22 +1687,13 @@ macro(build_substrait)
add_custom_target(substrait_gen ALL DEPENDS ${SUBSTRAIT_PROTO_GEN_ALL})
- add_arrow_lib(arrow_substrait- SOURCES- ${SUBSTRAIT_SOURCES}- DEPENDENCIES- substrait_gen- SHARED_LINK_LIBS- ${ARROW_PROTOBUF_LIBPROTOBUF}- STATIC_LINK_LIBS- ${ARROW_PROTOBUF_LIBPROTOBUF}- PRIVATE_INCLUDES- ${SUBSTRAIT_CPP_DIR})-- set(SUBSTRAIT_DEPENDENCIES substrait_gen)- set(SUBSTRAIT_SHARED arrow_substrait_shared)- set(SUBSTRAIT_STATIC arrow_substrait_static)- set(SUBSTRAIT_INCLUDES ${SUBSTRAIT_CPP_DIR})+ add_library(substrait OBJECT ${SUBSTRAIT_SOURCES})+ set_target_properties(substrait+ PROPERTIES+ INCLUDE_DIRECTORIES ${SUBSTRAIT_CPP_DIR}+ POSITION_INDEPENDENT_CODE ON)+ add_dependencies(substrait substrait_gen)+ get_target_property(SUBSTRAIT_INCLUDES substrait INCLUDE_DIRECTORIES)
endmacro()
if(ARROW_WITH_SUBSTRAIT)
diff --git a/cpp/src/arrow/engine/CMakeLists.txt b/cpp/src/arrow/engine/CMakeLists.txt
index 50a84464c0..ff88f47e4a 100644
--- a/cpp/src/arrow/engine/CMakeLists.txt+++ b/cpp/src/arrow/engine/CMakeLists.txt@@ -36,9 +36,10 @@ add_arrow_lib(arrow_engine
OUTPUTS
ARROW_ENGINE_LIBRARIES
DEPENDENCIES
- ${SUBSTRAIT_DEPENDENCIES}+ substrait
SOURCES
${ARROW_ENGINE_SRCS}
+ $<TARGET_OBJECTS:substrait>
PRECOMPILED_HEADERS
"$<$<COMPILE_LANGUAGE:CXX>:arrow/engine/pch.h>"
SHARED_LINK_FLAGS
@@ -46,11 +47,9 @@ add_arrow_lib(arrow_engine
SHARED_LINK_LIBS
arrow_shared
arrow_dataset_shared
- ${SUBSTRAIT_SHARED}
STATIC_LINK_LIBS
arrow_static
arrow_dataset_static
- ${SUBSTRAIT_STATIC}
PRIVATE_INCLUDES
${SUBSTRAIT_INCLUDES})

@jvanstraten

Copy link
Copy Markdown
ContributorAuthor

@kou Thanks for the input! It's certainly a lot nicer to do it that way, but unfortunately, we're not quite there yet... I got it working in most build environments using your diff with some minor changes (had to add protobuf to the include list for the object library, and add its runtime library to arrow_engine), but it fails here:

CMake Error at cmake_modules/BuildUtils.cmake:287 (add_library):
OBJECT library "arrow_engine_objlib" contains:
capabilities.pb.cc.o
expression.pb.cc.o
extensions.pb.cc.o
function.pb.cc.o
parameterized_types.pb.cc.o
plan.pb.cc.o
relations.pb.cc.o
type.pb.cc.o
type_expressions.pb.cc.o
but may contain only sources that compile, header files, and other files
that would not affect linking of a normal library.

I feel like the addition to BuildUtils.cmake is either causing this or supposed to resolve this (and failing to do so in this particular case), but other than that, my skill level for CMake is insufficient to see what exactly is going on here.

set(SUBSTRAIT_SOURCE_URL "$ENV{ARROW_SUBSTRAIT_URL}")
else()
set_urls(SUBSTRAIT_SOURCE_URL
"https://github.com/substrait-io/substrait/archive/${ARROW_SUBSTRAIT_BUILD_VERSION}.tar.gz"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1, this will be much better than involving some git commands.

Comment threadcpp/src/arrow/engine/CMakeLists.txt Outdated
substrait
SOURCES
${ARROW_ENGINE_SRCS}
$<TARGET_OBJECTS:substrait>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm... is there a particular reason for this? Should we instead create a static library containing these objects? Or perhaps I'm entirely misunderstanding this?

@koukouFeb 21, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can use a static library instead of an object library without using add_arrow_lib(). We can just use raw add_library().

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Looks like that's working, 577979b. I wasn't sure how generally-applicable linking static libraries with -fPIC into shared libraries would be. I'm also not sure why I still need to specify PRIVATE_INCLUDES ${SUBSTRAIT_INCLUDES} for the add_arrow_lib call (shouldn't CMake be propagating public include directories to dependent libraries?), but I couldn't get it to work without it.

@jvanstraten
jvanstraten marked this pull request as ready for review February 22, 2022 18:27
# under the License.

# Currently, we can only build Substrait from source.
set(SUBSTRAIT_FOUND NO)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we remove this file?
It seems that this file is never used.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Comment threadcpp/src/arrow/engine/CMakeLists.txt Outdated
Comment on lines +38 to +39
DEPENDENCIES
substrait

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we remove this?
This will be automatically added by using substrait target.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

It doesn't build (multithreaded) without it. I think it ensures that substrait is built completely prior to compilation of arrow_engine, rather than just prior to linking, which matters because arrow_engine uses generated code. Making it depend on substrait_gen would also work, if you prefer that option (IMO, the less arrow_engine depends on implementation details of ThirdpartyToolchain.cmake the better, so I set it to just substrait).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems that this is a problem of our add_arrow_lib():

diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake
index 391c43e0ac..7517e4e806 100644
--- a/cpp/cmake_modules/BuildUtils.cmake+++ b/cpp/cmake_modules/BuildUtils.cmake@@ -374,6 +374,13 @@ function(ADD_ARROW_LIB LIB_NAME)
"$<INSTALL_INTERFACE:${ARG_SHARED_INSTALL_INTERFACE_LIBS}>"
LINK_PRIVATE
${ARG_SHARED_PRIVATE_LINK_LIBS})
+ if(USE_OBJLIB)+ foreach(ARG_SHARED_LINK_LIB ${ARG_SHARED_LINK_LIBS})+ if(TARGET ${ARG_SHARED_LINK_LIB})+ add_dependencies(${LIB_NAME}_objlib ${ARG_SHARED_LINK_LIB})+ endif()+ endforeach()+ endif()
if(ARROW_RPATH_ORIGIN)
if(APPLE)
@@ -449,6 +456,13 @@ function(ADD_ARROW_LIB LIB_NAME)
if(ARG_STATIC_LINK_LIBS)
target_link_libraries(${LIB_NAME}_static LINK_PRIVATE
"$<BUILD_INTERFACE:${ARG_STATIC_LINK_LIBS}>")
+ if(USE_OBJLIB)+ foreach(ARG_STATIC_LINK_LIB ${ARG_STATIC_LINK_LIBS})+ if(TARGET ${ARG_STATIC_LINK_LIB})+ add_dependencies(${LIB_NAME}_objlib ${ARG_STATIC_LINK_LIB})+ endif()+ endforeach()+ endif()
endif()
install(TARGETS ${LIB_NAME}_static ${INSTALL_IS_OPTIONAL}
diff --git a/cpp/src/arrow/engine/CMakeLists.txt b/cpp/src/arrow/engine/CMakeLists.txt
index 13d50b4244..edb878939f 100644
--- a/cpp/src/arrow/engine/CMakeLists.txt+++ b/cpp/src/arrow/engine/CMakeLists.txt@@ -35,8 +35,6 @@ add_arrow_lib(arrow_engine
arrow-engine
OUTPUTS
ARROW_ENGINE_LIBRARIES
- DEPENDENCIES- substrait
SOURCES
${ARROW_ENGINE_SRCS}
PRECOMPILED_HEADERS

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Okay, that fixes it on my end, too. fffa65c

set_target_properties(substrait PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(substrait PUBLIC ${SUBSTRAIT_INCLUDES})
target_link_libraries(substrait INTERFACE ${ARROW_PROTOBUF_LIBPROTOBUF})
add_dependencies(substrait substrait_gen)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you add substrait to ARROW_BUNDLED_STATIC_LIBS?

Suggested change
add_dependencies(substraitsubstrait_gen)
list(APPEND ARROW_BUNDLED_STATIC_LIBS substrait)

If we don't add this, users can't link to libarrow_engine.a statically with libarrow_bundled_dependencies.a.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Added in 3d7bac9

The removal of add_dependencies(substrait substrait_gen) seems unrelated. I suppose it's technically redundant, since CMake will generate the .cc files by way of needing them as input for compiling substrait, and the .h files just so happen to be generated by the same command. If for whatever reason only the generated .h files are removed though, CMake won't know to recreate them without that rule.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, sorry. It's my fault.

@jvanstraten

Copy link
Copy Markdown
ContributorAuthor

Failure of AMD64 Ubuntu 20.04 GLib & Ruby for
fffa65c seems to be unrelated (zlib download failure, I think). It builds correctly when I run it with archery locally.

@kou

kou commented Feb 23, 2022

Copy link
Copy Markdown
Member

@github-actions crossbow submit python-sdist

@github-actions

Copy link
Copy Markdown

Revision: fffa65c

Submitted crossbow builds: ursacomputing/crossbow @ actions-1676

TaskStatus
python-sdistGithub Actions

@jvanstraten

Copy link
Copy Markdown
ContributorAuthor

@kou@pitrou@westonpace I believe this is ready to be merged, or am I still missing something?

LINK_PRIVATE
${ARG_SHARED_PRIVATE_LINK_LIBS})

if(USE_OBJLIB)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add a comment explaining this snippet?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Added something in c2380ee. @kou, please verify if what I wrote for it is correct and complete.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Right.

Comment threadcpp/cmake_modules/BuildUtils.cmake Outdated
${ARG_SHARED_PRIVATE_LINK_LIBS})

if(USE_OBJLIB)
foreach(ARG_SHARED_LINK_LIB ${ARG_SHARED_LINK_LIBS})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor, but naming ARG_SOMETHING a variable that is not one of the original function arguments is confusing.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Comment on lines +1677 to +1681
add_custom_command(OUTPUT "${SUBSTRAIT_PROTO_GEN}.${EXT}"
COMMAND ${ARROW_PROTOBUF_PROTOC} "-I${SUBSTRAIT_LOCAL_DIR}/proto"
"--cpp_out=${SUBSTRAIT_CPP_DIR}"
"${SUBSTRAIT_LOCAL_DIR}/proto/substrait/${SUBSTRAIT_PROTO}.proto"
DEPENDS ${PROTO_DEPENDS} substrait_ep)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems like it compiles each proto file twice (once per extension)? Is that desired?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

No, probably not. I noticed it too when I inherited this code, but incorrectly assumed it was written like that because add_custom_command only supported a single output file. 7ad2e1f

@pitrou

Copy link
Copy Markdown
Member

Perhaps @kou can also double-check the CMake changes.

@westonpacewestonpace left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have nothing further to add. I think this looks much nicer than what we had before. We might try and take some snippets from here and push them upstream into the Substrait project's documentation in some kind of "getting started with C++" section.

kou
kou approved these changes Feb 25, 2022

@koukou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1

LINK_PRIVATE
${ARG_SHARED_PRIVATE_LINK_LIBS})

if(USE_OBJLIB)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Right.

@koukou closed this in 89cc6b3Feb 25, 2022
@ursabot

ursabot commented Feb 25, 2022

Copy link
Copy Markdown

Benchmark runs are scheduled for baseline = acfd1d2 and contender = 89cc6b3. 89cc6b3 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Finished ⬇️0.21% ⬆️0.0%] test-mac-arm
[Finished ⬇️0.71% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️0.3% ⬆️0.0%] ursa-thinkcentre-m75q
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

marin-ma pushed a commit to marin-ma/arrow-1 that referenced this pull request Mar 28, 2022
…ine" build
This should fix:
- inline builds in general (ARROW-15709);
- [weird stuff with inline builds causing non-tracked files to be deleted](https://github.com/apache/arrow;/pull/12444#issuecomment-1043143303) that the [previous fix](apache#12444) for the above [caused](apache#12454)
- dependencies on git for downloading dependencies (ARROW-15760);
- the build process for Substrait previously being treated as something too special to use Arrow's normal method for dealing with third-party dependencies (i.e. `ThirdpartyToolchain.cmake`)
---
Initial attempt at making something functional to solve this issue properly.
The use of `add_arrow_lib` in `ThirdpartyToolchain.cmake` is certainly odd, and I'm sure I'm not following best practices in that file in general. I could use some advice on what the proper way to do this would be. Some of the issues:
- The CMake property specifying that a path refers to a generated file is scoped only to the current CMake file, so only moving the `externalproject_add` over to `ThirdpartyToolchain.cmake` resulted in the `add_arrow_lib` in `src/arrow/engine` failing due to missing source files. An object library didn't seem to resolve it either, and there are probably portability issues with that anyway, so that's why I ended up just using `add_arrow_lib`.
- Unlike all the other third-party dependencies (AFAICT), Substrait can't currently be installed, so `Substrait_SOURCE=SYSTEM` makes no sense. In the end I just decided to override it, but that's probably not ideal.
- Substrait doesn't have releases yet, so I had to resort to a git hash instead.
</details>
Closesapache#12457 from jvanstraten/ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi
Authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
(cherry picked from commit 89cc6b3)
zhouyuan pushed a commit to oap-project/arrow that referenced this pull request Apr 18, 2022
* ARROW-15238: [C++] ARROW_ENGINE module with substrait consumer
Continuation of apache#11707. I'm taking over from @bkietz for now because he's unavailable right now for personal reasons.
Closesapache#12279 from jvanstraten/substrait-consumer
Lead-authored-by: Benjamin Kietzman <bengilgit@gmail.com>
Co-authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Co-authored-by: Weston Pace <weston.pace@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
* ARROW-15700: [C++] Compilation error on Ubuntu 18.04
Modified Substrait consumer interaction with libprotobuf to support versions down to 3.0.0, which is the minimum required due to Substrait's usage of proto3 syntax.
Tested locally with:
```
export ARROW_PROTOBUF_URL=https://github.com/protocolbuffers/protobuf/releases/download/v3.0.0/protobuf-cpp-3.0.0.tar.gz
cmake \
--preset ninja-debug \
-DProtobuf_SOURCE=BUNDLED \
-DARROW_PROTOBUF_BUILD_VERSION=v3.0.0 \
-DARROW_PROTOBUF_BUILD_SHA256_CHECKSUM=318e8f375fb4e5333975a40e0d1215e855b4a8c581d692eb0eb7df70db1a8d4e
```
(Is there an easier way to do this without modifying versions.txt or 751fb9d? Also, the env var is needed only because Google isn't at all consistent with their release file naming that far back.)
It'd also be nice to add this to CI, but it's probably excessive to always run for a PR, unless combined with some other run.
Closesapache#12448 from jvanstraten/ARROW-15700-Compilation-error-on-Ubuntu-18-04
Authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
(cherry picked from commit 7d16a78)
* ARROW-15258: [C++] Easy options to create a source node from a table
This PR includes the addition of `TableSourceNode` to create a `ExecNode` easily using a table as the data source.
### TODO
- [x] Fix test case for chunk_size
Closesapache#12267 from vibhatha/arrow-15258-rb
Authored-by: Vibhatha Abeykoon <vibhatha@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
(cherry picked from commit fffdca2)
* ARROW-15709: [C++] Compilation of ARROW_ENGINE fails if doing an "inline" build
This should fix:
- inline builds in general (ARROW-15709);
- [weird stuff with inline builds causing non-tracked files to be deleted](https://github.com/apache/arrow;/pull/12444#issuecomment-1043143303) that the [previous fix](apache#12444) for the above [caused](apache#12454)
- dependencies on git for downloading dependencies (ARROW-15760);
- the build process for Substrait previously being treated as something too special to use Arrow's normal method for dealing with third-party dependencies (i.e. `ThirdpartyToolchain.cmake`)
---
Initial attempt at making something functional to solve this issue properly.
The use of `add_arrow_lib` in `ThirdpartyToolchain.cmake` is certainly odd, and I'm sure I'm not following best practices in that file in general. I could use some advice on what the proper way to do this would be. Some of the issues:
- The CMake property specifying that a path refers to a generated file is scoped only to the current CMake file, so only moving the `externalproject_add` over to `ThirdpartyToolchain.cmake` resulted in the `add_arrow_lib` in `src/arrow/engine` failing due to missing source files. An object library didn't seem to resolve it either, and there are probably portability issues with that anyway, so that's why I ended up just using `add_arrow_lib`.
- Unlike all the other third-party dependencies (AFAICT), Substrait can't currently be installed, so `Substrait_SOURCE=SYSTEM` makes no sense. In the end I just decided to override it, but that's probably not ideal.
- Substrait doesn't have releases yet, so I had to resort to a git hash instead.
</details>
Closesapache#12457 from jvanstraten/ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi
Authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
(cherry picked from commit 89cc6b3)
* ARROW-15830: [C++] Ensure target directory exists before running Substrait generation
Closesapache#12548 from pitrou/ARROW-15830-ubuntu-cpp-bundled
Authored-by: Antoine Pitrou <antoine@python.org>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
(cherry picked from commit e989fb3)
* ARROW-15850: [C++] Engine substrait headers missing from install
Closesapache#12569 from westonpace/feature/ARROW-15850--substrait-headers-missing
Authored-by: Weston Pace <weston.pace@gmail.com>
Signed-off-by: David Li <li.davidm96@gmail.com>
(cherry picked from commit 8fce593)
* Enable TPCH Q6 & Q1
Co-authored-by: Benjamin Kietzman <bengilgit@gmail.com>
Co-authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Co-authored-by: Weston Pace <weston.pace@gmail.com>
Co-authored-by: Vibhatha Abeykoon <vibhatha@gmail.com>
Co-authored-by: Antoine Pitrou <antoine@python.org>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@jvanstraten@westonpace@kou@pitrou@ursabot
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

ARROW-15709: [C++] Compilation of ARROW_ENGINE fails if doing an "inline" build - #12457

Closed
jvanstraten wants to merge 11 commits into
apache:masterfrom
jvanstraten:ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi
Closed

ARROW-15709: [C++] Compilation of ARROW_ENGINE fails if doing an "inline" build#12457
jvanstraten wants to merge 11 commits into
apache:masterfrom
jvanstraten:ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi

Conversation

@jvanstraten

@jvanstratenjvanstraten commented Feb 17, 2022

Copy link
Copy Markdown
Contributor

This should fix:


Initial attempt at making something functional to solve this issue properly.

The use of add_arrow_lib in ThirdpartyToolchain.cmake is certainly odd, and I'm sure I'm not following best practices in that file in general. I could use some advice on what the proper way to do this would be. Some of the issues:

  • The CMake property specifying that a path refers to a generated file is scoped only to the current CMake file, so only moving the externalproject_add over to ThirdpartyToolchain.cmake resulted in the add_arrow_lib in src/arrow/engine failing due to missing source files. An object library didn't seem to resolve it either, and there are probably portability issues with that anyway, so that's why I ended up just using add_arrow_lib.
  • Unlike all the other third-party dependencies (AFAICT), Substrait can't currently be installed, so Substrait_SOURCE=SYSTEM makes no sense. In the end I just decided to override it, but that's probably not ideal.
  • Substrait doesn't have releases yet, so I had to resort to a git hash instead.

@github-actions

Copy link
Copy Markdown

@westonpace

Copy link
Copy Markdown
Member

@kou@pitrou We could use input on this approach. The Substrait integration is a little unique because the .proto files themselves are not owned by us. We could fork a copy of the proto files but that would make keeping up with updated versions a bit tricky.

Protobuf is also a bit tricky because the version of the code generation tool (protoc) must match the version of the linked protobuf library exactly (this is different from flatbuffers which doesn't require a runtime dependency).

Previously we were downloading the proto files using git and running protoc within the engine directory. This had some negative side effects (#12454) mainly due to our use of git. Even beyond git however it was rather strange that this was resulting in a call to externalproject_add outside of ThirdPartyToolchain.cmake so @jvanstraten and I agreed it might be clear to treat Substrait as a "build-from-source only" third party dependency. This PR is @jvanstraten 's attempt to make that work but it is also odd as it requires a call to add_arrow_lib inside of ThirdPartyToolchain.cmake.

Any suggestions on a better approach or feedback on our current approach would be very much welcomed.

@jvanstraten
jvanstratenforce-pushed the ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi branch from a049bdd to fd6e5d4CompareFebruary 18, 2022 10:48
@kou

kou commented Feb 20, 2022

Copy link
Copy Markdown
Member

How about using just an OBJECT library https://cmake.org/cmake/help/latest/command/add_library.html#object-lib instead of arrow_add_lib()?

diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake
index 391c43e0ac..3afecfc562 100644
--- a/cpp/cmake_modules/BuildUtils.cmake+++ b/cpp/cmake_modules/BuildUtils.cmake@@ -297,6 +297,14 @@ function(ADD_ARROW_LIB LIB_NAME)
target_precompile_headers(${LIB_NAME}_objlib PRIVATE ${ARG_PRECOMPILED_HEADERS})
endif()
set(LIB_DEPS $<TARGET_OBJECTS:${LIB_NAME}_objlib>)
+ # We need to specify $<TARGET_OBJECTS:XXX> explicitly to SHARED+ # library and STATIC library because $<TARGET_OBJECTS:XXX> in+ # OBJECT isn't propagated to SHARED library and STATIC library.+ foreach(ARG_SOURCE ${ARG_SOURCES})+ if(ARG_SOURCE MATCHES "^\\$<TARGET_OBJECTS:")+ list(APPEND LIB_DEPS ${ARG_SOURCE})+ endif()+ endforeach()
set(LIB_INCLUDES)
set(EXTRA_DEPS)
diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index 8b53272452..9143550df9 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake@@ -1687,22 +1687,13 @@ macro(build_substrait)
add_custom_target(substrait_gen ALL DEPENDS ${SUBSTRAIT_PROTO_GEN_ALL})
- add_arrow_lib(arrow_substrait- SOURCES- ${SUBSTRAIT_SOURCES}- DEPENDENCIES- substrait_gen- SHARED_LINK_LIBS- ${ARROW_PROTOBUF_LIBPROTOBUF}- STATIC_LINK_LIBS- ${ARROW_PROTOBUF_LIBPROTOBUF}- PRIVATE_INCLUDES- ${SUBSTRAIT_CPP_DIR})-- set(SUBSTRAIT_DEPENDENCIES substrait_gen)- set(SUBSTRAIT_SHARED arrow_substrait_shared)- set(SUBSTRAIT_STATIC arrow_substrait_static)- set(SUBSTRAIT_INCLUDES ${SUBSTRAIT_CPP_DIR})+ add_library(substrait OBJECT ${SUBSTRAIT_SOURCES})+ set_target_properties(substrait+ PROPERTIES+ INCLUDE_DIRECTORIES ${SUBSTRAIT_CPP_DIR}+ POSITION_INDEPENDENT_CODE ON)+ add_dependencies(substrait substrait_gen)+ get_target_property(SUBSTRAIT_INCLUDES substrait INCLUDE_DIRECTORIES)
endmacro()
if(ARROW_WITH_SUBSTRAIT)
diff --git a/cpp/src/arrow/engine/CMakeLists.txt b/cpp/src/arrow/engine/CMakeLists.txt
index 50a84464c0..ff88f47e4a 100644
--- a/cpp/src/arrow/engine/CMakeLists.txt+++ b/cpp/src/arrow/engine/CMakeLists.txt@@ -36,9 +36,10 @@ add_arrow_lib(arrow_engine
OUTPUTS
ARROW_ENGINE_LIBRARIES
DEPENDENCIES
- ${SUBSTRAIT_DEPENDENCIES}+ substrait
SOURCES
${ARROW_ENGINE_SRCS}
+ $<TARGET_OBJECTS:substrait>
PRECOMPILED_HEADERS
"$<$<COMPILE_LANGUAGE:CXX>:arrow/engine/pch.h>"
SHARED_LINK_FLAGS
@@ -46,11 +47,9 @@ add_arrow_lib(arrow_engine
SHARED_LINK_LIBS
arrow_shared
arrow_dataset_shared
- ${SUBSTRAIT_SHARED}
STATIC_LINK_LIBS
arrow_static
arrow_dataset_static
- ${SUBSTRAIT_STATIC}
PRIVATE_INCLUDES
${SUBSTRAIT_INCLUDES})

@jvanstraten

Copy link
Copy Markdown
ContributorAuthor

@kou Thanks for the input! It's certainly a lot nicer to do it that way, but unfortunately, we're not quite there yet... I got it working in most build environments using your diff with some minor changes (had to add protobuf to the include list for the object library, and add its runtime library to arrow_engine), but it fails here:

CMake Error at cmake_modules/BuildUtils.cmake:287 (add_library):
OBJECT library "arrow_engine_objlib" contains:
capabilities.pb.cc.o
expression.pb.cc.o
extensions.pb.cc.o
function.pb.cc.o
parameterized_types.pb.cc.o
plan.pb.cc.o
relations.pb.cc.o
type.pb.cc.o
type_expressions.pb.cc.o
but may contain only sources that compile, header files, and other files
that would not affect linking of a normal library.

I feel like the addition to BuildUtils.cmake is either causing this or supposed to resolve this (and failing to do so in this particular case), but other than that, my skill level for CMake is insufficient to see what exactly is going on here.

set(SUBSTRAIT_SOURCE_URL "$ENV{ARROW_SUBSTRAIT_URL}")
else()
set_urls(SUBSTRAIT_SOURCE_URL
"https://github.com/substrait-io/substrait/archive/${ARROW_SUBSTRAIT_BUILD_VERSION}.tar.gz"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1, this will be much better than involving some git commands.

Comment threadcpp/src/arrow/engine/CMakeLists.txt Outdated
substrait
SOURCES
${ARROW_ENGINE_SRCS}
$<TARGET_OBJECTS:substrait>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm... is there a particular reason for this? Should we instead create a static library containing these objects? Or perhaps I'm entirely misunderstanding this?

@koukouFeb 21, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can use a static library instead of an object library without using add_arrow_lib(). We can just use raw add_library().

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Looks like that's working, 577979b. I wasn't sure how generally-applicable linking static libraries with -fPIC into shared libraries would be. I'm also not sure why I still need to specify PRIVATE_INCLUDES ${SUBSTRAIT_INCLUDES} for the add_arrow_lib call (shouldn't CMake be propagating public include directories to dependent libraries?), but I couldn't get it to work without it.

@jvanstraten
jvanstraten marked this pull request as ready for review February 22, 2022 18:27
# under the License.

# Currently, we can only build Substrait from source.
set(SUBSTRAIT_FOUND NO)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we remove this file?
It seems that this file is never used.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Comment threadcpp/src/arrow/engine/CMakeLists.txt Outdated
Comment on lines +38 to +39
DEPENDENCIES
substrait

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we remove this?
This will be automatically added by using substrait target.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

It doesn't build (multithreaded) without it. I think it ensures that substrait is built completely prior to compilation of arrow_engine, rather than just prior to linking, which matters because arrow_engine uses generated code. Making it depend on substrait_gen would also work, if you prefer that option (IMO, the less arrow_engine depends on implementation details of ThirdpartyToolchain.cmake the better, so I set it to just substrait).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems that this is a problem of our add_arrow_lib():

diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake
index 391c43e0ac..7517e4e806 100644
--- a/cpp/cmake_modules/BuildUtils.cmake+++ b/cpp/cmake_modules/BuildUtils.cmake@@ -374,6 +374,13 @@ function(ADD_ARROW_LIB LIB_NAME)
"$<INSTALL_INTERFACE:${ARG_SHARED_INSTALL_INTERFACE_LIBS}>"
LINK_PRIVATE
${ARG_SHARED_PRIVATE_LINK_LIBS})
+ if(USE_OBJLIB)+ foreach(ARG_SHARED_LINK_LIB ${ARG_SHARED_LINK_LIBS})+ if(TARGET ${ARG_SHARED_LINK_LIB})+ add_dependencies(${LIB_NAME}_objlib ${ARG_SHARED_LINK_LIB})+ endif()+ endforeach()+ endif()
if(ARROW_RPATH_ORIGIN)
if(APPLE)
@@ -449,6 +456,13 @@ function(ADD_ARROW_LIB LIB_NAME)
if(ARG_STATIC_LINK_LIBS)
target_link_libraries(${LIB_NAME}_static LINK_PRIVATE
"$<BUILD_INTERFACE:${ARG_STATIC_LINK_LIBS}>")
+ if(USE_OBJLIB)+ foreach(ARG_STATIC_LINK_LIB ${ARG_STATIC_LINK_LIBS})+ if(TARGET ${ARG_STATIC_LINK_LIB})+ add_dependencies(${LIB_NAME}_objlib ${ARG_STATIC_LINK_LIB})+ endif()+ endforeach()+ endif()
endif()
install(TARGETS ${LIB_NAME}_static ${INSTALL_IS_OPTIONAL}
diff --git a/cpp/src/arrow/engine/CMakeLists.txt b/cpp/src/arrow/engine/CMakeLists.txt
index 13d50b4244..edb878939f 100644
--- a/cpp/src/arrow/engine/CMakeLists.txt+++ b/cpp/src/arrow/engine/CMakeLists.txt@@ -35,8 +35,6 @@ add_arrow_lib(arrow_engine
arrow-engine
OUTPUTS
ARROW_ENGINE_LIBRARIES
- DEPENDENCIES- substrait
SOURCES
${ARROW_ENGINE_SRCS}
PRECOMPILED_HEADERS

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Okay, that fixes it on my end, too. fffa65c

set_target_properties(substrait PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(substrait PUBLIC ${SUBSTRAIT_INCLUDES})
target_link_libraries(substrait INTERFACE ${ARROW_PROTOBUF_LIBPROTOBUF})
add_dependencies(substrait substrait_gen)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you add substrait to ARROW_BUNDLED_STATIC_LIBS?

Suggested change
add_dependencies(substraitsubstrait_gen)
list(APPEND ARROW_BUNDLED_STATIC_LIBS substrait)

If we don't add this, users can't link to libarrow_engine.a statically with libarrow_bundled_dependencies.a.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Added in 3d7bac9

The removal of add_dependencies(substrait substrait_gen) seems unrelated. I suppose it's technically redundant, since CMake will generate the .cc files by way of needing them as input for compiling substrait, and the .h files just so happen to be generated by the same command. If for whatever reason only the generated .h files are removed though, CMake won't know to recreate them without that rule.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, sorry. It's my fault.

@jvanstraten

Copy link
Copy Markdown
ContributorAuthor

Failure of AMD64 Ubuntu 20.04 GLib & Ruby for
fffa65c seems to be unrelated (zlib download failure, I think). It builds correctly when I run it with archery locally.

@kou

kou commented Feb 23, 2022

Copy link
Copy Markdown
Member

@github-actions crossbow submit python-sdist

@github-actions

Copy link
Copy Markdown

Revision: fffa65c

Submitted crossbow builds: ursacomputing/crossbow @ actions-1676

TaskStatus
python-sdistGithub Actions

@jvanstraten

Copy link
Copy Markdown
ContributorAuthor

@kou@pitrou@westonpace I believe this is ready to be merged, or am I still missing something?

LINK_PRIVATE
${ARG_SHARED_PRIVATE_LINK_LIBS})

if(USE_OBJLIB)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add a comment explaining this snippet?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Added something in c2380ee. @kou, please verify if what I wrote for it is correct and complete.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Right.

Comment threadcpp/cmake_modules/BuildUtils.cmake Outdated
${ARG_SHARED_PRIVATE_LINK_LIBS})

if(USE_OBJLIB)
foreach(ARG_SHARED_LINK_LIB ${ARG_SHARED_LINK_LIBS})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor, but naming ARG_SOMETHING a variable that is not one of the original function arguments is confusing.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Comment on lines +1677 to +1681
add_custom_command(OUTPUT "${SUBSTRAIT_PROTO_GEN}.${EXT}"
COMMAND ${ARROW_PROTOBUF_PROTOC} "-I${SUBSTRAIT_LOCAL_DIR}/proto"
"--cpp_out=${SUBSTRAIT_CPP_DIR}"
"${SUBSTRAIT_LOCAL_DIR}/proto/substrait/${SUBSTRAIT_PROTO}.proto"
DEPENDS ${PROTO_DEPENDS} substrait_ep)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems like it compiles each proto file twice (once per extension)? Is that desired?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

No, probably not. I noticed it too when I inherited this code, but incorrectly assumed it was written like that because add_custom_command only supported a single output file. 7ad2e1f

@pitrou

Copy link
Copy Markdown
Member

Perhaps @kou can also double-check the CMake changes.

@westonpacewestonpace left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have nothing further to add. I think this looks much nicer than what we had before. We might try and take some snippets from here and push them upstream into the Substrait project's documentation in some kind of "getting started with C++" section.

kou
kou approved these changes Feb 25, 2022

@koukou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1

LINK_PRIVATE
${ARG_SHARED_PRIVATE_LINK_LIBS})

if(USE_OBJLIB)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Right.

@koukou closed this in 89cc6b3Feb 25, 2022
@ursabot

ursabot commented Feb 25, 2022

Copy link
Copy Markdown

Benchmark runs are scheduled for baseline = acfd1d2 and contender = 89cc6b3. 89cc6b3 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Finished ⬇️0.21% ⬆️0.0%] test-mac-arm
[Finished ⬇️0.71% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️0.3% ⬆️0.0%] ursa-thinkcentre-m75q
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

marin-ma pushed a commit to marin-ma/arrow-1 that referenced this pull request Mar 28, 2022
…ine" build
This should fix:
- inline builds in general (ARROW-15709);
- [weird stuff with inline builds causing non-tracked files to be deleted](https://github.com/apache/arrow;/pull/12444#issuecomment-1043143303) that the [previous fix](apache#12444) for the above [caused](apache#12454)
- dependencies on git for downloading dependencies (ARROW-15760);
- the build process for Substrait previously being treated as something too special to use Arrow's normal method for dealing with third-party dependencies (i.e. `ThirdpartyToolchain.cmake`)
---
Initial attempt at making something functional to solve this issue properly.
The use of `add_arrow_lib` in `ThirdpartyToolchain.cmake` is certainly odd, and I'm sure I'm not following best practices in that file in general. I could use some advice on what the proper way to do this would be. Some of the issues:
- The CMake property specifying that a path refers to a generated file is scoped only to the current CMake file, so only moving the `externalproject_add` over to `ThirdpartyToolchain.cmake` resulted in the `add_arrow_lib` in `src/arrow/engine` failing due to missing source files. An object library didn't seem to resolve it either, and there are probably portability issues with that anyway, so that's why I ended up just using `add_arrow_lib`.
- Unlike all the other third-party dependencies (AFAICT), Substrait can't currently be installed, so `Substrait_SOURCE=SYSTEM` makes no sense. In the end I just decided to override it, but that's probably not ideal.
- Substrait doesn't have releases yet, so I had to resort to a git hash instead.
</details>
Closesapache#12457 from jvanstraten/ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi
Authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
(cherry picked from commit 89cc6b3)
zhouyuan pushed a commit to oap-project/arrow that referenced this pull request Apr 18, 2022
* ARROW-15238: [C++] ARROW_ENGINE module with substrait consumer
Continuation of apache#11707. I'm taking over from @bkietz for now because he's unavailable right now for personal reasons.
Closesapache#12279 from jvanstraten/substrait-consumer
Lead-authored-by: Benjamin Kietzman <bengilgit@gmail.com>
Co-authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Co-authored-by: Weston Pace <weston.pace@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
* ARROW-15700: [C++] Compilation error on Ubuntu 18.04
Modified Substrait consumer interaction with libprotobuf to support versions down to 3.0.0, which is the minimum required due to Substrait's usage of proto3 syntax.
Tested locally with:
```
export ARROW_PROTOBUF_URL=https://github.com/protocolbuffers/protobuf/releases/download/v3.0.0/protobuf-cpp-3.0.0.tar.gz
cmake \
--preset ninja-debug \
-DProtobuf_SOURCE=BUNDLED \
-DARROW_PROTOBUF_BUILD_VERSION=v3.0.0 \
-DARROW_PROTOBUF_BUILD_SHA256_CHECKSUM=318e8f375fb4e5333975a40e0d1215e855b4a8c581d692eb0eb7df70db1a8d4e
```
(Is there an easier way to do this without modifying versions.txt or 751fb9d? Also, the env var is needed only because Google isn't at all consistent with their release file naming that far back.)
It'd also be nice to add this to CI, but it's probably excessive to always run for a PR, unless combined with some other run.
Closesapache#12448 from jvanstraten/ARROW-15700-Compilation-error-on-Ubuntu-18-04
Authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
(cherry picked from commit 7d16a78)
* ARROW-15258: [C++] Easy options to create a source node from a table
This PR includes the addition of `TableSourceNode` to create a `ExecNode` easily using a table as the data source.
### TODO
- [x] Fix test case for chunk_size
Closesapache#12267 from vibhatha/arrow-15258-rb
Authored-by: Vibhatha Abeykoon <vibhatha@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
(cherry picked from commit fffdca2)
* ARROW-15709: [C++] Compilation of ARROW_ENGINE fails if doing an "inline" build
This should fix:
- inline builds in general (ARROW-15709);
- [weird stuff with inline builds causing non-tracked files to be deleted](https://github.com/apache/arrow;/pull/12444#issuecomment-1043143303) that the [previous fix](apache#12444) for the above [caused](apache#12454)
- dependencies on git for downloading dependencies (ARROW-15760);
- the build process for Substrait previously being treated as something too special to use Arrow's normal method for dealing with third-party dependencies (i.e. `ThirdpartyToolchain.cmake`)
---
Initial attempt at making something functional to solve this issue properly.
The use of `add_arrow_lib` in `ThirdpartyToolchain.cmake` is certainly odd, and I'm sure I'm not following best practices in that file in general. I could use some advice on what the proper way to do this would be. Some of the issues:
- The CMake property specifying that a path refers to a generated file is scoped only to the current CMake file, so only moving the `externalproject_add` over to `ThirdpartyToolchain.cmake` resulted in the `add_arrow_lib` in `src/arrow/engine` failing due to missing source files. An object library didn't seem to resolve it either, and there are probably portability issues with that anyway, so that's why I ended up just using `add_arrow_lib`.
- Unlike all the other third-party dependencies (AFAICT), Substrait can't currently be installed, so `Substrait_SOURCE=SYSTEM` makes no sense. In the end I just decided to override it, but that's probably not ideal.
- Substrait doesn't have releases yet, so I had to resort to a git hash instead.
</details>
Closesapache#12457 from jvanstraten/ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi
Authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
(cherry picked from commit 89cc6b3)
* ARROW-15830: [C++] Ensure target directory exists before running Substrait generation
Closesapache#12548 from pitrou/ARROW-15830-ubuntu-cpp-bundled
Authored-by: Antoine Pitrou <antoine@python.org>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
(cherry picked from commit e989fb3)
* ARROW-15850: [C++] Engine substrait headers missing from install
Closesapache#12569 from westonpace/feature/ARROW-15850--substrait-headers-missing
Authored-by: Weston Pace <weston.pace@gmail.com>
Signed-off-by: David Li <li.davidm96@gmail.com>
(cherry picked from commit 8fce593)
* Enable TPCH Q6 & Q1
Co-authored-by: Benjamin Kietzman <bengilgit@gmail.com>
Co-authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Co-authored-by: Weston Pace <weston.pace@gmail.com>
Co-authored-by: Vibhatha Abeykoon <vibhatha@gmail.com>
Co-authored-by: Antoine Pitrou <antoine@python.org>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@jvanstraten@westonpace@kou@pitrou@ursabot
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

ARROW-15709: [C++] Compilation of ARROW_ENGINE fails if doing an "inline" build - #12457

Closed
jvanstraten wants to merge 11 commits into
apache:masterfrom
jvanstraten:ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi
Closed

ARROW-15709: [C++] Compilation of ARROW_ENGINE fails if doing an "inline" build#12457
jvanstraten wants to merge 11 commits into
apache:masterfrom
jvanstraten:ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi

Conversation

@jvanstraten

@jvanstratenjvanstraten commented Feb 17, 2022

Copy link
Copy Markdown
Contributor

This should fix:


Initial attempt at making something functional to solve this issue properly.

The use of add_arrow_lib in ThirdpartyToolchain.cmake is certainly odd, and I'm sure I'm not following best practices in that file in general. I could use some advice on what the proper way to do this would be. Some of the issues:

  • The CMake property specifying that a path refers to a generated file is scoped only to the current CMake file, so only moving the externalproject_add over to ThirdpartyToolchain.cmake resulted in the add_arrow_lib in src/arrow/engine failing due to missing source files. An object library didn't seem to resolve it either, and there are probably portability issues with that anyway, so that's why I ended up just using add_arrow_lib.
  • Unlike all the other third-party dependencies (AFAICT), Substrait can't currently be installed, so Substrait_SOURCE=SYSTEM makes no sense. In the end I just decided to override it, but that's probably not ideal.
  • Substrait doesn't have releases yet, so I had to resort to a git hash instead.

@github-actions

Copy link
Copy Markdown

@westonpace

Copy link
Copy Markdown
Member

@kou@pitrou We could use input on this approach. The Substrait integration is a little unique because the .proto files themselves are not owned by us. We could fork a copy of the proto files but that would make keeping up with updated versions a bit tricky.

Protobuf is also a bit tricky because the version of the code generation tool (protoc) must match the version of the linked protobuf library exactly (this is different from flatbuffers which doesn't require a runtime dependency).

Previously we were downloading the proto files using git and running protoc within the engine directory. This had some negative side effects (#12454) mainly due to our use of git. Even beyond git however it was rather strange that this was resulting in a call to externalproject_add outside of ThirdPartyToolchain.cmake so @jvanstraten and I agreed it might be clear to treat Substrait as a "build-from-source only" third party dependency. This PR is @jvanstraten 's attempt to make that work but it is also odd as it requires a call to add_arrow_lib inside of ThirdPartyToolchain.cmake.

Any suggestions on a better approach or feedback on our current approach would be very much welcomed.

@jvanstraten
jvanstratenforce-pushed the ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi branch from a049bdd to fd6e5d4CompareFebruary 18, 2022 10:48
@kou

kou commented Feb 20, 2022

Copy link
Copy Markdown
Member

How about using just an OBJECT library https://cmake.org/cmake/help/latest/command/add_library.html#object-lib instead of arrow_add_lib()?

diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake
index 391c43e0ac..3afecfc562 100644
--- a/cpp/cmake_modules/BuildUtils.cmake+++ b/cpp/cmake_modules/BuildUtils.cmake@@ -297,6 +297,14 @@ function(ADD_ARROW_LIB LIB_NAME)
target_precompile_headers(${LIB_NAME}_objlib PRIVATE ${ARG_PRECOMPILED_HEADERS})
endif()
set(LIB_DEPS $<TARGET_OBJECTS:${LIB_NAME}_objlib>)
+ # We need to specify $<TARGET_OBJECTS:XXX> explicitly to SHARED+ # library and STATIC library because $<TARGET_OBJECTS:XXX> in+ # OBJECT isn't propagated to SHARED library and STATIC library.+ foreach(ARG_SOURCE ${ARG_SOURCES})+ if(ARG_SOURCE MATCHES "^\\$<TARGET_OBJECTS:")+ list(APPEND LIB_DEPS ${ARG_SOURCE})+ endif()+ endforeach()
set(LIB_INCLUDES)
set(EXTRA_DEPS)
diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index 8b53272452..9143550df9 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake@@ -1687,22 +1687,13 @@ macro(build_substrait)
add_custom_target(substrait_gen ALL DEPENDS ${SUBSTRAIT_PROTO_GEN_ALL})
- add_arrow_lib(arrow_substrait- SOURCES- ${SUBSTRAIT_SOURCES}- DEPENDENCIES- substrait_gen- SHARED_LINK_LIBS- ${ARROW_PROTOBUF_LIBPROTOBUF}- STATIC_LINK_LIBS- ${ARROW_PROTOBUF_LIBPROTOBUF}- PRIVATE_INCLUDES- ${SUBSTRAIT_CPP_DIR})-- set(SUBSTRAIT_DEPENDENCIES substrait_gen)- set(SUBSTRAIT_SHARED arrow_substrait_shared)- set(SUBSTRAIT_STATIC arrow_substrait_static)- set(SUBSTRAIT_INCLUDES ${SUBSTRAIT_CPP_DIR})+ add_library(substrait OBJECT ${SUBSTRAIT_SOURCES})+ set_target_properties(substrait+ PROPERTIES+ INCLUDE_DIRECTORIES ${SUBSTRAIT_CPP_DIR}+ POSITION_INDEPENDENT_CODE ON)+ add_dependencies(substrait substrait_gen)+ get_target_property(SUBSTRAIT_INCLUDES substrait INCLUDE_DIRECTORIES)
endmacro()
if(ARROW_WITH_SUBSTRAIT)
diff --git a/cpp/src/arrow/engine/CMakeLists.txt b/cpp/src/arrow/engine/CMakeLists.txt
index 50a84464c0..ff88f47e4a 100644
--- a/cpp/src/arrow/engine/CMakeLists.txt+++ b/cpp/src/arrow/engine/CMakeLists.txt@@ -36,9 +36,10 @@ add_arrow_lib(arrow_engine
OUTPUTS
ARROW_ENGINE_LIBRARIES
DEPENDENCIES
- ${SUBSTRAIT_DEPENDENCIES}+ substrait
SOURCES
${ARROW_ENGINE_SRCS}
+ $<TARGET_OBJECTS:substrait>
PRECOMPILED_HEADERS
"$<$<COMPILE_LANGUAGE:CXX>:arrow/engine/pch.h>"
SHARED_LINK_FLAGS
@@ -46,11 +47,9 @@ add_arrow_lib(arrow_engine
SHARED_LINK_LIBS
arrow_shared
arrow_dataset_shared
- ${SUBSTRAIT_SHARED}
STATIC_LINK_LIBS
arrow_static
arrow_dataset_static
- ${SUBSTRAIT_STATIC}
PRIVATE_INCLUDES
${SUBSTRAIT_INCLUDES})

@jvanstraten

Copy link
Copy Markdown
ContributorAuthor

@kou Thanks for the input! It's certainly a lot nicer to do it that way, but unfortunately, we're not quite there yet... I got it working in most build environments using your diff with some minor changes (had to add protobuf to the include list for the object library, and add its runtime library to arrow_engine), but it fails here:

CMake Error at cmake_modules/BuildUtils.cmake:287 (add_library):
OBJECT library "arrow_engine_objlib" contains:
capabilities.pb.cc.o
expression.pb.cc.o
extensions.pb.cc.o
function.pb.cc.o
parameterized_types.pb.cc.o
plan.pb.cc.o
relations.pb.cc.o
type.pb.cc.o
type_expressions.pb.cc.o
but may contain only sources that compile, header files, and other files
that would not affect linking of a normal library.

I feel like the addition to BuildUtils.cmake is either causing this or supposed to resolve this (and failing to do so in this particular case), but other than that, my skill level for CMake is insufficient to see what exactly is going on here.

set(SUBSTRAIT_SOURCE_URL "$ENV{ARROW_SUBSTRAIT_URL}")
else()
set_urls(SUBSTRAIT_SOURCE_URL
"https://github.com/substrait-io/substrait/archive/${ARROW_SUBSTRAIT_BUILD_VERSION}.tar.gz"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1, this will be much better than involving some git commands.

Comment threadcpp/src/arrow/engine/CMakeLists.txt Outdated
substrait
SOURCES
${ARROW_ENGINE_SRCS}
$<TARGET_OBJECTS:substrait>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm... is there a particular reason for this? Should we instead create a static library containing these objects? Or perhaps I'm entirely misunderstanding this?

@koukouFeb 21, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can use a static library instead of an object library without using add_arrow_lib(). We can just use raw add_library().

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Looks like that's working, 577979b. I wasn't sure how generally-applicable linking static libraries with -fPIC into shared libraries would be. I'm also not sure why I still need to specify PRIVATE_INCLUDES ${SUBSTRAIT_INCLUDES} for the add_arrow_lib call (shouldn't CMake be propagating public include directories to dependent libraries?), but I couldn't get it to work without it.

@jvanstraten
jvanstraten marked this pull request as ready for review February 22, 2022 18:27
# under the License.

# Currently, we can only build Substrait from source.
set(SUBSTRAIT_FOUND NO)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we remove this file?
It seems that this file is never used.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Comment threadcpp/src/arrow/engine/CMakeLists.txt Outdated
Comment on lines +38 to +39
DEPENDENCIES
substrait

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we remove this?
This will be automatically added by using substrait target.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

It doesn't build (multithreaded) without it. I think it ensures that substrait is built completely prior to compilation of arrow_engine, rather than just prior to linking, which matters because arrow_engine uses generated code. Making it depend on substrait_gen would also work, if you prefer that option (IMO, the less arrow_engine depends on implementation details of ThirdpartyToolchain.cmake the better, so I set it to just substrait).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems that this is a problem of our add_arrow_lib():

diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake
index 391c43e0ac..7517e4e806 100644
--- a/cpp/cmake_modules/BuildUtils.cmake+++ b/cpp/cmake_modules/BuildUtils.cmake@@ -374,6 +374,13 @@ function(ADD_ARROW_LIB LIB_NAME)
"$<INSTALL_INTERFACE:${ARG_SHARED_INSTALL_INTERFACE_LIBS}>"
LINK_PRIVATE
${ARG_SHARED_PRIVATE_LINK_LIBS})
+ if(USE_OBJLIB)+ foreach(ARG_SHARED_LINK_LIB ${ARG_SHARED_LINK_LIBS})+ if(TARGET ${ARG_SHARED_LINK_LIB})+ add_dependencies(${LIB_NAME}_objlib ${ARG_SHARED_LINK_LIB})+ endif()+ endforeach()+ endif()
if(ARROW_RPATH_ORIGIN)
if(APPLE)
@@ -449,6 +456,13 @@ function(ADD_ARROW_LIB LIB_NAME)
if(ARG_STATIC_LINK_LIBS)
target_link_libraries(${LIB_NAME}_static LINK_PRIVATE
"$<BUILD_INTERFACE:${ARG_STATIC_LINK_LIBS}>")
+ if(USE_OBJLIB)+ foreach(ARG_STATIC_LINK_LIB ${ARG_STATIC_LINK_LIBS})+ if(TARGET ${ARG_STATIC_LINK_LIB})+ add_dependencies(${LIB_NAME}_objlib ${ARG_STATIC_LINK_LIB})+ endif()+ endforeach()+ endif()
endif()
install(TARGETS ${LIB_NAME}_static ${INSTALL_IS_OPTIONAL}
diff --git a/cpp/src/arrow/engine/CMakeLists.txt b/cpp/src/arrow/engine/CMakeLists.txt
index 13d50b4244..edb878939f 100644
--- a/cpp/src/arrow/engine/CMakeLists.txt+++ b/cpp/src/arrow/engine/CMakeLists.txt@@ -35,8 +35,6 @@ add_arrow_lib(arrow_engine
arrow-engine
OUTPUTS
ARROW_ENGINE_LIBRARIES
- DEPENDENCIES- substrait
SOURCES
${ARROW_ENGINE_SRCS}
PRECOMPILED_HEADERS

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Okay, that fixes it on my end, too. fffa65c

set_target_properties(substrait PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(substrait PUBLIC ${SUBSTRAIT_INCLUDES})
target_link_libraries(substrait INTERFACE ${ARROW_PROTOBUF_LIBPROTOBUF})
add_dependencies(substrait substrait_gen)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you add substrait to ARROW_BUNDLED_STATIC_LIBS?

Suggested change
add_dependencies(substraitsubstrait_gen)
list(APPEND ARROW_BUNDLED_STATIC_LIBS substrait)

If we don't add this, users can't link to libarrow_engine.a statically with libarrow_bundled_dependencies.a.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Added in 3d7bac9

The removal of add_dependencies(substrait substrait_gen) seems unrelated. I suppose it's technically redundant, since CMake will generate the .cc files by way of needing them as input for compiling substrait, and the .h files just so happen to be generated by the same command. If for whatever reason only the generated .h files are removed though, CMake won't know to recreate them without that rule.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, sorry. It's my fault.

@jvanstraten

Copy link
Copy Markdown
ContributorAuthor

Failure of AMD64 Ubuntu 20.04 GLib & Ruby for
fffa65c seems to be unrelated (zlib download failure, I think). It builds correctly when I run it with archery locally.

@kou

kou commented Feb 23, 2022

Copy link
Copy Markdown
Member

@github-actions crossbow submit python-sdist

@github-actions

Copy link
Copy Markdown

Revision: fffa65c

Submitted crossbow builds: ursacomputing/crossbow @ actions-1676

TaskStatus
python-sdistGithub Actions

@jvanstraten

Copy link
Copy Markdown
ContributorAuthor

@kou@pitrou@westonpace I believe this is ready to be merged, or am I still missing something?

LINK_PRIVATE
${ARG_SHARED_PRIVATE_LINK_LIBS})

if(USE_OBJLIB)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add a comment explaining this snippet?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Added something in c2380ee. @kou, please verify if what I wrote for it is correct and complete.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Right.

Comment threadcpp/cmake_modules/BuildUtils.cmake Outdated
${ARG_SHARED_PRIVATE_LINK_LIBS})

if(USE_OBJLIB)
foreach(ARG_SHARED_LINK_LIB ${ARG_SHARED_LINK_LIBS})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor, but naming ARG_SOMETHING a variable that is not one of the original function arguments is confusing.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Comment on lines +1677 to +1681
add_custom_command(OUTPUT "${SUBSTRAIT_PROTO_GEN}.${EXT}"
COMMAND ${ARROW_PROTOBUF_PROTOC} "-I${SUBSTRAIT_LOCAL_DIR}/proto"
"--cpp_out=${SUBSTRAIT_CPP_DIR}"
"${SUBSTRAIT_LOCAL_DIR}/proto/substrait/${SUBSTRAIT_PROTO}.proto"
DEPENDS ${PROTO_DEPENDS} substrait_ep)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems like it compiles each proto file twice (once per extension)? Is that desired?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

No, probably not. I noticed it too when I inherited this code, but incorrectly assumed it was written like that because add_custom_command only supported a single output file. 7ad2e1f

@pitrou

Copy link
Copy Markdown
Member

Perhaps @kou can also double-check the CMake changes.

@westonpacewestonpace left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have nothing further to add. I think this looks much nicer than what we had before. We might try and take some snippets from here and push them upstream into the Substrait project's documentation in some kind of "getting started with C++" section.

kou
kou approved these changes Feb 25, 2022

@koukou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1

LINK_PRIVATE
${ARG_SHARED_PRIVATE_LINK_LIBS})

if(USE_OBJLIB)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Right.

@koukou closed this in 89cc6b3Feb 25, 2022
@ursabot

ursabot commented Feb 25, 2022

Copy link
Copy Markdown

Benchmark runs are scheduled for baseline = acfd1d2 and contender = 89cc6b3. 89cc6b3 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Finished ⬇️0.21% ⬆️0.0%] test-mac-arm
[Finished ⬇️0.71% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️0.3% ⬆️0.0%] ursa-thinkcentre-m75q
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

marin-ma pushed a commit to marin-ma/arrow-1 that referenced this pull request Mar 28, 2022
…ine" build
This should fix:
- inline builds in general (ARROW-15709);
- [weird stuff with inline builds causing non-tracked files to be deleted](https://github.com/apache/arrow;/pull/12444#issuecomment-1043143303) that the [previous fix](apache#12444) for the above [caused](apache#12454)
- dependencies on git for downloading dependencies (ARROW-15760);
- the build process for Substrait previously being treated as something too special to use Arrow's normal method for dealing with third-party dependencies (i.e. `ThirdpartyToolchain.cmake`)
---
Initial attempt at making something functional to solve this issue properly.
The use of `add_arrow_lib` in `ThirdpartyToolchain.cmake` is certainly odd, and I'm sure I'm not following best practices in that file in general. I could use some advice on what the proper way to do this would be. Some of the issues:
- The CMake property specifying that a path refers to a generated file is scoped only to the current CMake file, so only moving the `externalproject_add` over to `ThirdpartyToolchain.cmake` resulted in the `add_arrow_lib` in `src/arrow/engine` failing due to missing source files. An object library didn't seem to resolve it either, and there are probably portability issues with that anyway, so that's why I ended up just using `add_arrow_lib`.
- Unlike all the other third-party dependencies (AFAICT), Substrait can't currently be installed, so `Substrait_SOURCE=SYSTEM` makes no sense. In the end I just decided to override it, but that's probably not ideal.
- Substrait doesn't have releases yet, so I had to resort to a git hash instead.
</details>
Closesapache#12457 from jvanstraten/ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi
Authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
(cherry picked from commit 89cc6b3)
zhouyuan pushed a commit to oap-project/arrow that referenced this pull request Apr 18, 2022
* ARROW-15238: [C++] ARROW_ENGINE module with substrait consumer
Continuation of apache#11707. I'm taking over from @bkietz for now because he's unavailable right now for personal reasons.
Closesapache#12279 from jvanstraten/substrait-consumer
Lead-authored-by: Benjamin Kietzman <bengilgit@gmail.com>
Co-authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Co-authored-by: Weston Pace <weston.pace@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
* ARROW-15700: [C++] Compilation error on Ubuntu 18.04
Modified Substrait consumer interaction with libprotobuf to support versions down to 3.0.0, which is the minimum required due to Substrait's usage of proto3 syntax.
Tested locally with:
```
export ARROW_PROTOBUF_URL=https://github.com/protocolbuffers/protobuf/releases/download/v3.0.0/protobuf-cpp-3.0.0.tar.gz
cmake \
--preset ninja-debug \
-DProtobuf_SOURCE=BUNDLED \
-DARROW_PROTOBUF_BUILD_VERSION=v3.0.0 \
-DARROW_PROTOBUF_BUILD_SHA256_CHECKSUM=318e8f375fb4e5333975a40e0d1215e855b4a8c581d692eb0eb7df70db1a8d4e
```
(Is there an easier way to do this without modifying versions.txt or 751fb9d? Also, the env var is needed only because Google isn't at all consistent with their release file naming that far back.)
It'd also be nice to add this to CI, but it's probably excessive to always run for a PR, unless combined with some other run.
Closesapache#12448 from jvanstraten/ARROW-15700-Compilation-error-on-Ubuntu-18-04
Authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
(cherry picked from commit 7d16a78)
* ARROW-15258: [C++] Easy options to create a source node from a table
This PR includes the addition of `TableSourceNode` to create a `ExecNode` easily using a table as the data source.
### TODO
- [x] Fix test case for chunk_size
Closesapache#12267 from vibhatha/arrow-15258-rb
Authored-by: Vibhatha Abeykoon <vibhatha@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
(cherry picked from commit fffdca2)
* ARROW-15709: [C++] Compilation of ARROW_ENGINE fails if doing an "inline" build
This should fix:
- inline builds in general (ARROW-15709);
- [weird stuff with inline builds causing non-tracked files to be deleted](https://github.com/apache/arrow;/pull/12444#issuecomment-1043143303) that the [previous fix](apache#12444) for the above [caused](apache#12454)
- dependencies on git for downloading dependencies (ARROW-15760);
- the build process for Substrait previously being treated as something too special to use Arrow's normal method for dealing with third-party dependencies (i.e. `ThirdpartyToolchain.cmake`)
---
Initial attempt at making something functional to solve this issue properly.
The use of `add_arrow_lib` in `ThirdpartyToolchain.cmake` is certainly odd, and I'm sure I'm not following best practices in that file in general. I could use some advice on what the proper way to do this would be. Some of the issues:
- The CMake property specifying that a path refers to a generated file is scoped only to the current CMake file, so only moving the `externalproject_add` over to `ThirdpartyToolchain.cmake` resulted in the `add_arrow_lib` in `src/arrow/engine` failing due to missing source files. An object library didn't seem to resolve it either, and there are probably portability issues with that anyway, so that's why I ended up just using `add_arrow_lib`.
- Unlike all the other third-party dependencies (AFAICT), Substrait can't currently be installed, so `Substrait_SOURCE=SYSTEM` makes no sense. In the end I just decided to override it, but that's probably not ideal.
- Substrait doesn't have releases yet, so I had to resort to a git hash instead.
</details>
Closesapache#12457 from jvanstraten/ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi
Authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
(cherry picked from commit 89cc6b3)
* ARROW-15830: [C++] Ensure target directory exists before running Substrait generation
Closesapache#12548 from pitrou/ARROW-15830-ubuntu-cpp-bundled
Authored-by: Antoine Pitrou <antoine@python.org>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
(cherry picked from commit e989fb3)
* ARROW-15850: [C++] Engine substrait headers missing from install
Closesapache#12569 from westonpace/feature/ARROW-15850--substrait-headers-missing
Authored-by: Weston Pace <weston.pace@gmail.com>
Signed-off-by: David Li <li.davidm96@gmail.com>
(cherry picked from commit 8fce593)
* Enable TPCH Q6 & Q1
Co-authored-by: Benjamin Kietzman <bengilgit@gmail.com>
Co-authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Co-authored-by: Weston Pace <weston.pace@gmail.com>
Co-authored-by: Vibhatha Abeykoon <vibhatha@gmail.com>
Co-authored-by: Antoine Pitrou <antoine@python.org>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@jvanstraten@westonpace@kou@pitrou@ursabot
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

ARROW-15709: [C++] Compilation of ARROW_ENGINE fails if doing an "inline" build - #12457

Closed
jvanstraten wants to merge 11 commits into
apache:masterfrom
jvanstraten:ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi
Closed

ARROW-15709: [C++] Compilation of ARROW_ENGINE fails if doing an "inline" build#12457
jvanstraten wants to merge 11 commits into
apache:masterfrom
jvanstraten:ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi

Conversation

@jvanstraten

@jvanstratenjvanstraten commented Feb 17, 2022

Copy link
Copy Markdown
Contributor

This should fix:


Initial attempt at making something functional to solve this issue properly.

The use of add_arrow_lib in ThirdpartyToolchain.cmake is certainly odd, and I'm sure I'm not following best practices in that file in general. I could use some advice on what the proper way to do this would be. Some of the issues:

  • The CMake property specifying that a path refers to a generated file is scoped only to the current CMake file, so only moving the externalproject_add over to ThirdpartyToolchain.cmake resulted in the add_arrow_lib in src/arrow/engine failing due to missing source files. An object library didn't seem to resolve it either, and there are probably portability issues with that anyway, so that's why I ended up just using add_arrow_lib.
  • Unlike all the other third-party dependencies (AFAICT), Substrait can't currently be installed, so Substrait_SOURCE=SYSTEM makes no sense. In the end I just decided to override it, but that's probably not ideal.
  • Substrait doesn't have releases yet, so I had to resort to a git hash instead.

@github-actions

Copy link
Copy Markdown

@westonpace

Copy link
Copy Markdown
Member

@kou@pitrou We could use input on this approach. The Substrait integration is a little unique because the .proto files themselves are not owned by us. We could fork a copy of the proto files but that would make keeping up with updated versions a bit tricky.

Protobuf is also a bit tricky because the version of the code generation tool (protoc) must match the version of the linked protobuf library exactly (this is different from flatbuffers which doesn't require a runtime dependency).

Previously we were downloading the proto files using git and running protoc within the engine directory. This had some negative side effects (#12454) mainly due to our use of git. Even beyond git however it was rather strange that this was resulting in a call to externalproject_add outside of ThirdPartyToolchain.cmake so @jvanstraten and I agreed it might be clear to treat Substrait as a "build-from-source only" third party dependency. This PR is @jvanstraten 's attempt to make that work but it is also odd as it requires a call to add_arrow_lib inside of ThirdPartyToolchain.cmake.

Any suggestions on a better approach or feedback on our current approach would be very much welcomed.

@jvanstraten
jvanstratenforce-pushed the ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi branch from a049bdd to fd6e5d4CompareFebruary 18, 2022 10:48
@kou

kou commented Feb 20, 2022

Copy link
Copy Markdown
Member

How about using just an OBJECT library https://cmake.org/cmake/help/latest/command/add_library.html#object-lib instead of arrow_add_lib()?

diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake
index 391c43e0ac..3afecfc562 100644
--- a/cpp/cmake_modules/BuildUtils.cmake+++ b/cpp/cmake_modules/BuildUtils.cmake@@ -297,6 +297,14 @@ function(ADD_ARROW_LIB LIB_NAME)
target_precompile_headers(${LIB_NAME}_objlib PRIVATE ${ARG_PRECOMPILED_HEADERS})
endif()
set(LIB_DEPS $<TARGET_OBJECTS:${LIB_NAME}_objlib>)
+ # We need to specify $<TARGET_OBJECTS:XXX> explicitly to SHARED+ # library and STATIC library because $<TARGET_OBJECTS:XXX> in+ # OBJECT isn't propagated to SHARED library and STATIC library.+ foreach(ARG_SOURCE ${ARG_SOURCES})+ if(ARG_SOURCE MATCHES "^\\$<TARGET_OBJECTS:")+ list(APPEND LIB_DEPS ${ARG_SOURCE})+ endif()+ endforeach()
set(LIB_INCLUDES)
set(EXTRA_DEPS)
diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index 8b53272452..9143550df9 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake@@ -1687,22 +1687,13 @@ macro(build_substrait)
add_custom_target(substrait_gen ALL DEPENDS ${SUBSTRAIT_PROTO_GEN_ALL})
- add_arrow_lib(arrow_substrait- SOURCES- ${SUBSTRAIT_SOURCES}- DEPENDENCIES- substrait_gen- SHARED_LINK_LIBS- ${ARROW_PROTOBUF_LIBPROTOBUF}- STATIC_LINK_LIBS- ${ARROW_PROTOBUF_LIBPROTOBUF}- PRIVATE_INCLUDES- ${SUBSTRAIT_CPP_DIR})-- set(SUBSTRAIT_DEPENDENCIES substrait_gen)- set(SUBSTRAIT_SHARED arrow_substrait_shared)- set(SUBSTRAIT_STATIC arrow_substrait_static)- set(SUBSTRAIT_INCLUDES ${SUBSTRAIT_CPP_DIR})+ add_library(substrait OBJECT ${SUBSTRAIT_SOURCES})+ set_target_properties(substrait+ PROPERTIES+ INCLUDE_DIRECTORIES ${SUBSTRAIT_CPP_DIR}+ POSITION_INDEPENDENT_CODE ON)+ add_dependencies(substrait substrait_gen)+ get_target_property(SUBSTRAIT_INCLUDES substrait INCLUDE_DIRECTORIES)
endmacro()
if(ARROW_WITH_SUBSTRAIT)
diff --git a/cpp/src/arrow/engine/CMakeLists.txt b/cpp/src/arrow/engine/CMakeLists.txt
index 50a84464c0..ff88f47e4a 100644
--- a/cpp/src/arrow/engine/CMakeLists.txt+++ b/cpp/src/arrow/engine/CMakeLists.txt@@ -36,9 +36,10 @@ add_arrow_lib(arrow_engine
OUTPUTS
ARROW_ENGINE_LIBRARIES
DEPENDENCIES
- ${SUBSTRAIT_DEPENDENCIES}+ substrait
SOURCES
${ARROW_ENGINE_SRCS}
+ $<TARGET_OBJECTS:substrait>
PRECOMPILED_HEADERS
"$<$<COMPILE_LANGUAGE:CXX>:arrow/engine/pch.h>"
SHARED_LINK_FLAGS
@@ -46,11 +47,9 @@ add_arrow_lib(arrow_engine
SHARED_LINK_LIBS
arrow_shared
arrow_dataset_shared
- ${SUBSTRAIT_SHARED}
STATIC_LINK_LIBS
arrow_static
arrow_dataset_static
- ${SUBSTRAIT_STATIC}
PRIVATE_INCLUDES
${SUBSTRAIT_INCLUDES})

@jvanstraten

Copy link
Copy Markdown
ContributorAuthor

@kou Thanks for the input! It's certainly a lot nicer to do it that way, but unfortunately, we're not quite there yet... I got it working in most build environments using your diff with some minor changes (had to add protobuf to the include list for the object library, and add its runtime library to arrow_engine), but it fails here:

CMake Error at cmake_modules/BuildUtils.cmake:287 (add_library):
OBJECT library "arrow_engine_objlib" contains:
capabilities.pb.cc.o
expression.pb.cc.o
extensions.pb.cc.o
function.pb.cc.o
parameterized_types.pb.cc.o
plan.pb.cc.o
relations.pb.cc.o
type.pb.cc.o
type_expressions.pb.cc.o
but may contain only sources that compile, header files, and other files
that would not affect linking of a normal library.

I feel like the addition to BuildUtils.cmake is either causing this or supposed to resolve this (and failing to do so in this particular case), but other than that, my skill level for CMake is insufficient to see what exactly is going on here.

set(SUBSTRAIT_SOURCE_URL "$ENV{ARROW_SUBSTRAIT_URL}")
else()
set_urls(SUBSTRAIT_SOURCE_URL
"https://github.com/substrait-io/substrait/archive/${ARROW_SUBSTRAIT_BUILD_VERSION}.tar.gz"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1, this will be much better than involving some git commands.

Comment threadcpp/src/arrow/engine/CMakeLists.txt Outdated
substrait
SOURCES
${ARROW_ENGINE_SRCS}
$<TARGET_OBJECTS:substrait>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm... is there a particular reason for this? Should we instead create a static library containing these objects? Or perhaps I'm entirely misunderstanding this?

@koukouFeb 21, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can use a static library instead of an object library without using add_arrow_lib(). We can just use raw add_library().

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Looks like that's working, 577979b. I wasn't sure how generally-applicable linking static libraries with -fPIC into shared libraries would be. I'm also not sure why I still need to specify PRIVATE_INCLUDES ${SUBSTRAIT_INCLUDES} for the add_arrow_lib call (shouldn't CMake be propagating public include directories to dependent libraries?), but I couldn't get it to work without it.

@jvanstraten
jvanstraten marked this pull request as ready for review February 22, 2022 18:27
# under the License.

# Currently, we can only build Substrait from source.
set(SUBSTRAIT_FOUND NO)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we remove this file?
It seems that this file is never used.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Comment threadcpp/src/arrow/engine/CMakeLists.txt Outdated
Comment on lines +38 to +39
DEPENDENCIES
substrait

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we remove this?
This will be automatically added by using substrait target.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

It doesn't build (multithreaded) without it. I think it ensures that substrait is built completely prior to compilation of arrow_engine, rather than just prior to linking, which matters because arrow_engine uses generated code. Making it depend on substrait_gen would also work, if you prefer that option (IMO, the less arrow_engine depends on implementation details of ThirdpartyToolchain.cmake the better, so I set it to just substrait).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems that this is a problem of our add_arrow_lib():

diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake
index 391c43e0ac..7517e4e806 100644
--- a/cpp/cmake_modules/BuildUtils.cmake+++ b/cpp/cmake_modules/BuildUtils.cmake@@ -374,6 +374,13 @@ function(ADD_ARROW_LIB LIB_NAME)
"$<INSTALL_INTERFACE:${ARG_SHARED_INSTALL_INTERFACE_LIBS}>"
LINK_PRIVATE
${ARG_SHARED_PRIVATE_LINK_LIBS})
+ if(USE_OBJLIB)+ foreach(ARG_SHARED_LINK_LIB ${ARG_SHARED_LINK_LIBS})+ if(TARGET ${ARG_SHARED_LINK_LIB})+ add_dependencies(${LIB_NAME}_objlib ${ARG_SHARED_LINK_LIB})+ endif()+ endforeach()+ endif()
if(ARROW_RPATH_ORIGIN)
if(APPLE)
@@ -449,6 +456,13 @@ function(ADD_ARROW_LIB LIB_NAME)
if(ARG_STATIC_LINK_LIBS)
target_link_libraries(${LIB_NAME}_static LINK_PRIVATE
"$<BUILD_INTERFACE:${ARG_STATIC_LINK_LIBS}>")
+ if(USE_OBJLIB)+ foreach(ARG_STATIC_LINK_LIB ${ARG_STATIC_LINK_LIBS})+ if(TARGET ${ARG_STATIC_LINK_LIB})+ add_dependencies(${LIB_NAME}_objlib ${ARG_STATIC_LINK_LIB})+ endif()+ endforeach()+ endif()
endif()
install(TARGETS ${LIB_NAME}_static ${INSTALL_IS_OPTIONAL}
diff --git a/cpp/src/arrow/engine/CMakeLists.txt b/cpp/src/arrow/engine/CMakeLists.txt
index 13d50b4244..edb878939f 100644
--- a/cpp/src/arrow/engine/CMakeLists.txt+++ b/cpp/src/arrow/engine/CMakeLists.txt@@ -35,8 +35,6 @@ add_arrow_lib(arrow_engine
arrow-engine
OUTPUTS
ARROW_ENGINE_LIBRARIES
- DEPENDENCIES- substrait
SOURCES
${ARROW_ENGINE_SRCS}
PRECOMPILED_HEADERS

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Okay, that fixes it on my end, too. fffa65c

set_target_properties(substrait PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(substrait PUBLIC ${SUBSTRAIT_INCLUDES})
target_link_libraries(substrait INTERFACE ${ARROW_PROTOBUF_LIBPROTOBUF})
add_dependencies(substrait substrait_gen)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you add substrait to ARROW_BUNDLED_STATIC_LIBS?

Suggested change
add_dependencies(substraitsubstrait_gen)
list(APPEND ARROW_BUNDLED_STATIC_LIBS substrait)

If we don't add this, users can't link to libarrow_engine.a statically with libarrow_bundled_dependencies.a.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Added in 3d7bac9

The removal of add_dependencies(substrait substrait_gen) seems unrelated. I suppose it's technically redundant, since CMake will generate the .cc files by way of needing them as input for compiling substrait, and the .h files just so happen to be generated by the same command. If for whatever reason only the generated .h files are removed though, CMake won't know to recreate them without that rule.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, sorry. It's my fault.

@jvanstraten

Copy link
Copy Markdown
ContributorAuthor

Failure of AMD64 Ubuntu 20.04 GLib & Ruby for
fffa65c seems to be unrelated (zlib download failure, I think). It builds correctly when I run it with archery locally.

@kou

kou commented Feb 23, 2022

Copy link
Copy Markdown
Member

@github-actions crossbow submit python-sdist

@github-actions

Copy link
Copy Markdown

Revision: fffa65c

Submitted crossbow builds: ursacomputing/crossbow @ actions-1676

TaskStatus
python-sdistGithub Actions

@jvanstraten

Copy link
Copy Markdown
ContributorAuthor

@kou@pitrou@westonpace I believe this is ready to be merged, or am I still missing something?

LINK_PRIVATE
${ARG_SHARED_PRIVATE_LINK_LIBS})

if(USE_OBJLIB)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add a comment explaining this snippet?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Added something in c2380ee. @kou, please verify if what I wrote for it is correct and complete.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Right.

Comment threadcpp/cmake_modules/BuildUtils.cmake Outdated
${ARG_SHARED_PRIVATE_LINK_LIBS})

if(USE_OBJLIB)
foreach(ARG_SHARED_LINK_LIB ${ARG_SHARED_LINK_LIBS})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor, but naming ARG_SOMETHING a variable that is not one of the original function arguments is confusing.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Comment on lines +1677 to +1681
add_custom_command(OUTPUT "${SUBSTRAIT_PROTO_GEN}.${EXT}"
COMMAND ${ARROW_PROTOBUF_PROTOC} "-I${SUBSTRAIT_LOCAL_DIR}/proto"
"--cpp_out=${SUBSTRAIT_CPP_DIR}"
"${SUBSTRAIT_LOCAL_DIR}/proto/substrait/${SUBSTRAIT_PROTO}.proto"
DEPENDS ${PROTO_DEPENDS} substrait_ep)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems like it compiles each proto file twice (once per extension)? Is that desired?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

No, probably not. I noticed it too when I inherited this code, but incorrectly assumed it was written like that because add_custom_command only supported a single output file. 7ad2e1f

@pitrou

Copy link
Copy Markdown
Member

Perhaps @kou can also double-check the CMake changes.

@westonpacewestonpace left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have nothing further to add. I think this looks much nicer than what we had before. We might try and take some snippets from here and push them upstream into the Substrait project's documentation in some kind of "getting started with C++" section.

kou
kou approved these changes Feb 25, 2022

@koukou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1

LINK_PRIVATE
${ARG_SHARED_PRIVATE_LINK_LIBS})

if(USE_OBJLIB)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Right.

@koukou closed this in 89cc6b3Feb 25, 2022
@ursabot

ursabot commented Feb 25, 2022

Copy link
Copy Markdown

Benchmark runs are scheduled for baseline = acfd1d2 and contender = 89cc6b3. 89cc6b3 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Finished ⬇️0.21% ⬆️0.0%] test-mac-arm
[Finished ⬇️0.71% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️0.3% ⬆️0.0%] ursa-thinkcentre-m75q
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

marin-ma pushed a commit to marin-ma/arrow-1 that referenced this pull request Mar 28, 2022
…ine" build
This should fix:
- inline builds in general (ARROW-15709);
- [weird stuff with inline builds causing non-tracked files to be deleted](https://github.com/apache/arrow;/pull/12444#issuecomment-1043143303) that the [previous fix](apache#12444) for the above [caused](apache#12454)
- dependencies on git for downloading dependencies (ARROW-15760);
- the build process for Substrait previously being treated as something too special to use Arrow's normal method for dealing with third-party dependencies (i.e. `ThirdpartyToolchain.cmake`)
---
Initial attempt at making something functional to solve this issue properly.
The use of `add_arrow_lib` in `ThirdpartyToolchain.cmake` is certainly odd, and I'm sure I'm not following best practices in that file in general. I could use some advice on what the proper way to do this would be. Some of the issues:
- The CMake property specifying that a path refers to a generated file is scoped only to the current CMake file, so only moving the `externalproject_add` over to `ThirdpartyToolchain.cmake` resulted in the `add_arrow_lib` in `src/arrow/engine` failing due to missing source files. An object library didn't seem to resolve it either, and there are probably portability issues with that anyway, so that's why I ended up just using `add_arrow_lib`.
- Unlike all the other third-party dependencies (AFAICT), Substrait can't currently be installed, so `Substrait_SOURCE=SYSTEM` makes no sense. In the end I just decided to override it, but that's probably not ideal.
- Substrait doesn't have releases yet, so I had to resort to a git hash instead.
</details>
Closesapache#12457 from jvanstraten/ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi
Authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
(cherry picked from commit 89cc6b3)
zhouyuan pushed a commit to oap-project/arrow that referenced this pull request Apr 18, 2022
* ARROW-15238: [C++] ARROW_ENGINE module with substrait consumer
Continuation of apache#11707. I'm taking over from @bkietz for now because he's unavailable right now for personal reasons.
Closesapache#12279 from jvanstraten/substrait-consumer
Lead-authored-by: Benjamin Kietzman <bengilgit@gmail.com>
Co-authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Co-authored-by: Weston Pace <weston.pace@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
* ARROW-15700: [C++] Compilation error on Ubuntu 18.04
Modified Substrait consumer interaction with libprotobuf to support versions down to 3.0.0, which is the minimum required due to Substrait's usage of proto3 syntax.
Tested locally with:
```
export ARROW_PROTOBUF_URL=https://github.com/protocolbuffers/protobuf/releases/download/v3.0.0/protobuf-cpp-3.0.0.tar.gz
cmake \
--preset ninja-debug \
-DProtobuf_SOURCE=BUNDLED \
-DARROW_PROTOBUF_BUILD_VERSION=v3.0.0 \
-DARROW_PROTOBUF_BUILD_SHA256_CHECKSUM=318e8f375fb4e5333975a40e0d1215e855b4a8c581d692eb0eb7df70db1a8d4e
```
(Is there an easier way to do this without modifying versions.txt or 751fb9d? Also, the env var is needed only because Google isn't at all consistent with their release file naming that far back.)
It'd also be nice to add this to CI, but it's probably excessive to always run for a PR, unless combined with some other run.
Closesapache#12448 from jvanstraten/ARROW-15700-Compilation-error-on-Ubuntu-18-04
Authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
(cherry picked from commit 7d16a78)
* ARROW-15258: [C++] Easy options to create a source node from a table
This PR includes the addition of `TableSourceNode` to create a `ExecNode` easily using a table as the data source.
### TODO
- [x] Fix test case for chunk_size
Closesapache#12267 from vibhatha/arrow-15258-rb
Authored-by: Vibhatha Abeykoon <vibhatha@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
(cherry picked from commit fffdca2)
* ARROW-15709: [C++] Compilation of ARROW_ENGINE fails if doing an "inline" build
This should fix:
- inline builds in general (ARROW-15709);
- [weird stuff with inline builds causing non-tracked files to be deleted](https://github.com/apache/arrow;/pull/12444#issuecomment-1043143303) that the [previous fix](apache#12444) for the above [caused](apache#12454)
- dependencies on git for downloading dependencies (ARROW-15760);
- the build process for Substrait previously being treated as something too special to use Arrow's normal method for dealing with third-party dependencies (i.e. `ThirdpartyToolchain.cmake`)
---
Initial attempt at making something functional to solve this issue properly.
The use of `add_arrow_lib` in `ThirdpartyToolchain.cmake` is certainly odd, and I'm sure I'm not following best practices in that file in general. I could use some advice on what the proper way to do this would be. Some of the issues:
- The CMake property specifying that a path refers to a generated file is scoped only to the current CMake file, so only moving the `externalproject_add` over to `ThirdpartyToolchain.cmake` resulted in the `add_arrow_lib` in `src/arrow/engine` failing due to missing source files. An object library didn't seem to resolve it either, and there are probably portability issues with that anyway, so that's why I ended up just using `add_arrow_lib`.
- Unlike all the other third-party dependencies (AFAICT), Substrait can't currently be installed, so `Substrait_SOURCE=SYSTEM` makes no sense. In the end I just decided to override it, but that's probably not ideal.
- Substrait doesn't have releases yet, so I had to resort to a git hash instead.
</details>
Closesapache#12457 from jvanstraten/ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi
Authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
(cherry picked from commit 89cc6b3)
* ARROW-15830: [C++] Ensure target directory exists before running Substrait generation
Closesapache#12548 from pitrou/ARROW-15830-ubuntu-cpp-bundled
Authored-by: Antoine Pitrou <antoine@python.org>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
(cherry picked from commit e989fb3)
* ARROW-15850: [C++] Engine substrait headers missing from install
Closesapache#12569 from westonpace/feature/ARROW-15850--substrait-headers-missing
Authored-by: Weston Pace <weston.pace@gmail.com>
Signed-off-by: David Li <li.davidm96@gmail.com>
(cherry picked from commit 8fce593)
* Enable TPCH Q6 & Q1
Co-authored-by: Benjamin Kietzman <bengilgit@gmail.com>
Co-authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Co-authored-by: Weston Pace <weston.pace@gmail.com>
Co-authored-by: Vibhatha Abeykoon <vibhatha@gmail.com>
Co-authored-by: Antoine Pitrou <antoine@python.org>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@jvanstraten@westonpace@kou@pitrou@ursabot
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

ARROW-15709: [C++] Compilation of ARROW_ENGINE fails if doing an "inline" build - #12457

Closed
jvanstraten wants to merge 11 commits into
apache:masterfrom
jvanstraten:ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi
Closed

ARROW-15709: [C++] Compilation of ARROW_ENGINE fails if doing an "inline" build#12457
jvanstraten wants to merge 11 commits into
apache:masterfrom
jvanstraten:ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi

Conversation

@jvanstraten

@jvanstratenjvanstraten commented Feb 17, 2022

Copy link
Copy Markdown
Contributor

This should fix:


Initial attempt at making something functional to solve this issue properly.

The use of add_arrow_lib in ThirdpartyToolchain.cmake is certainly odd, and I'm sure I'm not following best practices in that file in general. I could use some advice on what the proper way to do this would be. Some of the issues:

  • The CMake property specifying that a path refers to a generated file is scoped only to the current CMake file, so only moving the externalproject_add over to ThirdpartyToolchain.cmake resulted in the add_arrow_lib in src/arrow/engine failing due to missing source files. An object library didn't seem to resolve it either, and there are probably portability issues with that anyway, so that's why I ended up just using add_arrow_lib.
  • Unlike all the other third-party dependencies (AFAICT), Substrait can't currently be installed, so Substrait_SOURCE=SYSTEM makes no sense. In the end I just decided to override it, but that's probably not ideal.
  • Substrait doesn't have releases yet, so I had to resort to a git hash instead.

@github-actions

Copy link
Copy Markdown

@westonpace

Copy link
Copy Markdown
Member

@kou@pitrou We could use input on this approach. The Substrait integration is a little unique because the .proto files themselves are not owned by us. We could fork a copy of the proto files but that would make keeping up with updated versions a bit tricky.

Protobuf is also a bit tricky because the version of the code generation tool (protoc) must match the version of the linked protobuf library exactly (this is different from flatbuffers which doesn't require a runtime dependency).

Previously we were downloading the proto files using git and running protoc within the engine directory. This had some negative side effects (#12454) mainly due to our use of git. Even beyond git however it was rather strange that this was resulting in a call to externalproject_add outside of ThirdPartyToolchain.cmake so @jvanstraten and I agreed it might be clear to treat Substrait as a "build-from-source only" third party dependency. This PR is @jvanstraten 's attempt to make that work but it is also odd as it requires a call to add_arrow_lib inside of ThirdPartyToolchain.cmake.

Any suggestions on a better approach or feedback on our current approach would be very much welcomed.

@jvanstraten
jvanstratenforce-pushed the ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi branch from a049bdd to fd6e5d4CompareFebruary 18, 2022 10:48
@kou

kou commented Feb 20, 2022

Copy link
Copy Markdown
Member

How about using just an OBJECT library https://cmake.org/cmake/help/latest/command/add_library.html#object-lib instead of arrow_add_lib()?

diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake
index 391c43e0ac..3afecfc562 100644
--- a/cpp/cmake_modules/BuildUtils.cmake+++ b/cpp/cmake_modules/BuildUtils.cmake@@ -297,6 +297,14 @@ function(ADD_ARROW_LIB LIB_NAME)
target_precompile_headers(${LIB_NAME}_objlib PRIVATE ${ARG_PRECOMPILED_HEADERS})
endif()
set(LIB_DEPS $<TARGET_OBJECTS:${LIB_NAME}_objlib>)
+ # We need to specify $<TARGET_OBJECTS:XXX> explicitly to SHARED+ # library and STATIC library because $<TARGET_OBJECTS:XXX> in+ # OBJECT isn't propagated to SHARED library and STATIC library.+ foreach(ARG_SOURCE ${ARG_SOURCES})+ if(ARG_SOURCE MATCHES "^\\$<TARGET_OBJECTS:")+ list(APPEND LIB_DEPS ${ARG_SOURCE})+ endif()+ endforeach()
set(LIB_INCLUDES)
set(EXTRA_DEPS)
diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index 8b53272452..9143550df9 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake@@ -1687,22 +1687,13 @@ macro(build_substrait)
add_custom_target(substrait_gen ALL DEPENDS ${SUBSTRAIT_PROTO_GEN_ALL})
- add_arrow_lib(arrow_substrait- SOURCES- ${SUBSTRAIT_SOURCES}- DEPENDENCIES- substrait_gen- SHARED_LINK_LIBS- ${ARROW_PROTOBUF_LIBPROTOBUF}- STATIC_LINK_LIBS- ${ARROW_PROTOBUF_LIBPROTOBUF}- PRIVATE_INCLUDES- ${SUBSTRAIT_CPP_DIR})-- set(SUBSTRAIT_DEPENDENCIES substrait_gen)- set(SUBSTRAIT_SHARED arrow_substrait_shared)- set(SUBSTRAIT_STATIC arrow_substrait_static)- set(SUBSTRAIT_INCLUDES ${SUBSTRAIT_CPP_DIR})+ add_library(substrait OBJECT ${SUBSTRAIT_SOURCES})+ set_target_properties(substrait+ PROPERTIES+ INCLUDE_DIRECTORIES ${SUBSTRAIT_CPP_DIR}+ POSITION_INDEPENDENT_CODE ON)+ add_dependencies(substrait substrait_gen)+ get_target_property(SUBSTRAIT_INCLUDES substrait INCLUDE_DIRECTORIES)
endmacro()
if(ARROW_WITH_SUBSTRAIT)
diff --git a/cpp/src/arrow/engine/CMakeLists.txt b/cpp/src/arrow/engine/CMakeLists.txt
index 50a84464c0..ff88f47e4a 100644
--- a/cpp/src/arrow/engine/CMakeLists.txt+++ b/cpp/src/arrow/engine/CMakeLists.txt@@ -36,9 +36,10 @@ add_arrow_lib(arrow_engine
OUTPUTS
ARROW_ENGINE_LIBRARIES
DEPENDENCIES
- ${SUBSTRAIT_DEPENDENCIES}+ substrait
SOURCES
${ARROW_ENGINE_SRCS}
+ $<TARGET_OBJECTS:substrait>
PRECOMPILED_HEADERS
"$<$<COMPILE_LANGUAGE:CXX>:arrow/engine/pch.h>"
SHARED_LINK_FLAGS
@@ -46,11 +47,9 @@ add_arrow_lib(arrow_engine
SHARED_LINK_LIBS
arrow_shared
arrow_dataset_shared
- ${SUBSTRAIT_SHARED}
STATIC_LINK_LIBS
arrow_static
arrow_dataset_static
- ${SUBSTRAIT_STATIC}
PRIVATE_INCLUDES
${SUBSTRAIT_INCLUDES})

@jvanstraten

Copy link
Copy Markdown
ContributorAuthor

@kou Thanks for the input! It's certainly a lot nicer to do it that way, but unfortunately, we're not quite there yet... I got it working in most build environments using your diff with some minor changes (had to add protobuf to the include list for the object library, and add its runtime library to arrow_engine), but it fails here:

CMake Error at cmake_modules/BuildUtils.cmake:287 (add_library):
OBJECT library "arrow_engine_objlib" contains:
capabilities.pb.cc.o
expression.pb.cc.o
extensions.pb.cc.o
function.pb.cc.o
parameterized_types.pb.cc.o
plan.pb.cc.o
relations.pb.cc.o
type.pb.cc.o
type_expressions.pb.cc.o
but may contain only sources that compile, header files, and other files
that would not affect linking of a normal library.

I feel like the addition to BuildUtils.cmake is either causing this or supposed to resolve this (and failing to do so in this particular case), but other than that, my skill level for CMake is insufficient to see what exactly is going on here.

set(SUBSTRAIT_SOURCE_URL "$ENV{ARROW_SUBSTRAIT_URL}")
else()
set_urls(SUBSTRAIT_SOURCE_URL
"https://github.com/substrait-io/substrait/archive/${ARROW_SUBSTRAIT_BUILD_VERSION}.tar.gz"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1, this will be much better than involving some git commands.

Comment threadcpp/src/arrow/engine/CMakeLists.txt Outdated
substrait
SOURCES
${ARROW_ENGINE_SRCS}
$<TARGET_OBJECTS:substrait>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm... is there a particular reason for this? Should we instead create a static library containing these objects? Or perhaps I'm entirely misunderstanding this?

@koukouFeb 21, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can use a static library instead of an object library without using add_arrow_lib(). We can just use raw add_library().

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Looks like that's working, 577979b. I wasn't sure how generally-applicable linking static libraries with -fPIC into shared libraries would be. I'm also not sure why I still need to specify PRIVATE_INCLUDES ${SUBSTRAIT_INCLUDES} for the add_arrow_lib call (shouldn't CMake be propagating public include directories to dependent libraries?), but I couldn't get it to work without it.

@jvanstraten
jvanstraten marked this pull request as ready for review February 22, 2022 18:27
# under the License.

# Currently, we can only build Substrait from source.
set(SUBSTRAIT_FOUND NO)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we remove this file?
It seems that this file is never used.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Comment threadcpp/src/arrow/engine/CMakeLists.txt Outdated
Comment on lines +38 to +39
DEPENDENCIES
substrait

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we remove this?
This will be automatically added by using substrait target.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

It doesn't build (multithreaded) without it. I think it ensures that substrait is built completely prior to compilation of arrow_engine, rather than just prior to linking, which matters because arrow_engine uses generated code. Making it depend on substrait_gen would also work, if you prefer that option (IMO, the less arrow_engine depends on implementation details of ThirdpartyToolchain.cmake the better, so I set it to just substrait).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems that this is a problem of our add_arrow_lib():

diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake
index 391c43e0ac..7517e4e806 100644
--- a/cpp/cmake_modules/BuildUtils.cmake+++ b/cpp/cmake_modules/BuildUtils.cmake@@ -374,6 +374,13 @@ function(ADD_ARROW_LIB LIB_NAME)
"$<INSTALL_INTERFACE:${ARG_SHARED_INSTALL_INTERFACE_LIBS}>"
LINK_PRIVATE
${ARG_SHARED_PRIVATE_LINK_LIBS})
+ if(USE_OBJLIB)+ foreach(ARG_SHARED_LINK_LIB ${ARG_SHARED_LINK_LIBS})+ if(TARGET ${ARG_SHARED_LINK_LIB})+ add_dependencies(${LIB_NAME}_objlib ${ARG_SHARED_LINK_LIB})+ endif()+ endforeach()+ endif()
if(ARROW_RPATH_ORIGIN)
if(APPLE)
@@ -449,6 +456,13 @@ function(ADD_ARROW_LIB LIB_NAME)
if(ARG_STATIC_LINK_LIBS)
target_link_libraries(${LIB_NAME}_static LINK_PRIVATE
"$<BUILD_INTERFACE:${ARG_STATIC_LINK_LIBS}>")
+ if(USE_OBJLIB)+ foreach(ARG_STATIC_LINK_LIB ${ARG_STATIC_LINK_LIBS})+ if(TARGET ${ARG_STATIC_LINK_LIB})+ add_dependencies(${LIB_NAME}_objlib ${ARG_STATIC_LINK_LIB})+ endif()+ endforeach()+ endif()
endif()
install(TARGETS ${LIB_NAME}_static ${INSTALL_IS_OPTIONAL}
diff --git a/cpp/src/arrow/engine/CMakeLists.txt b/cpp/src/arrow/engine/CMakeLists.txt
index 13d50b4244..edb878939f 100644
--- a/cpp/src/arrow/engine/CMakeLists.txt+++ b/cpp/src/arrow/engine/CMakeLists.txt@@ -35,8 +35,6 @@ add_arrow_lib(arrow_engine
arrow-engine
OUTPUTS
ARROW_ENGINE_LIBRARIES
- DEPENDENCIES- substrait
SOURCES
${ARROW_ENGINE_SRCS}
PRECOMPILED_HEADERS

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Okay, that fixes it on my end, too. fffa65c

set_target_properties(substrait PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(substrait PUBLIC ${SUBSTRAIT_INCLUDES})
target_link_libraries(substrait INTERFACE ${ARROW_PROTOBUF_LIBPROTOBUF})
add_dependencies(substrait substrait_gen)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you add substrait to ARROW_BUNDLED_STATIC_LIBS?

Suggested change
add_dependencies(substraitsubstrait_gen)
list(APPEND ARROW_BUNDLED_STATIC_LIBS substrait)

If we don't add this, users can't link to libarrow_engine.a statically with libarrow_bundled_dependencies.a.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Added in 3d7bac9

The removal of add_dependencies(substrait substrait_gen) seems unrelated. I suppose it's technically redundant, since CMake will generate the .cc files by way of needing them as input for compiling substrait, and the .h files just so happen to be generated by the same command. If for whatever reason only the generated .h files are removed though, CMake won't know to recreate them without that rule.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, sorry. It's my fault.

@jvanstraten

Copy link
Copy Markdown
ContributorAuthor

Failure of AMD64 Ubuntu 20.04 GLib & Ruby for
fffa65c seems to be unrelated (zlib download failure, I think). It builds correctly when I run it with archery locally.

@kou

kou commented Feb 23, 2022

Copy link
Copy Markdown
Member

@github-actions crossbow submit python-sdist

@github-actions

Copy link
Copy Markdown

Revision: fffa65c

Submitted crossbow builds: ursacomputing/crossbow @ actions-1676

TaskStatus
python-sdistGithub Actions

@jvanstraten

Copy link
Copy Markdown
ContributorAuthor

@kou@pitrou@westonpace I believe this is ready to be merged, or am I still missing something?

LINK_PRIVATE
${ARG_SHARED_PRIVATE_LINK_LIBS})

if(USE_OBJLIB)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add a comment explaining this snippet?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Added something in c2380ee. @kou, please verify if what I wrote for it is correct and complete.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Right.

Comment threadcpp/cmake_modules/BuildUtils.cmake Outdated
${ARG_SHARED_PRIVATE_LINK_LIBS})

if(USE_OBJLIB)
foreach(ARG_SHARED_LINK_LIB ${ARG_SHARED_LINK_LIBS})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor, but naming ARG_SOMETHING a variable that is not one of the original function arguments is confusing.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Comment on lines +1677 to +1681
add_custom_command(OUTPUT "${SUBSTRAIT_PROTO_GEN}.${EXT}"
COMMAND ${ARROW_PROTOBUF_PROTOC} "-I${SUBSTRAIT_LOCAL_DIR}/proto"
"--cpp_out=${SUBSTRAIT_CPP_DIR}"
"${SUBSTRAIT_LOCAL_DIR}/proto/substrait/${SUBSTRAIT_PROTO}.proto"
DEPENDS ${PROTO_DEPENDS} substrait_ep)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems like it compiles each proto file twice (once per extension)? Is that desired?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

No, probably not. I noticed it too when I inherited this code, but incorrectly assumed it was written like that because add_custom_command only supported a single output file. 7ad2e1f

@pitrou

Copy link
Copy Markdown
Member

Perhaps @kou can also double-check the CMake changes.

@westonpacewestonpace left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have nothing further to add. I think this looks much nicer than what we had before. We might try and take some snippets from here and push them upstream into the Substrait project's documentation in some kind of "getting started with C++" section.

kou
kou approved these changes Feb 25, 2022

@koukou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1

LINK_PRIVATE
${ARG_SHARED_PRIVATE_LINK_LIBS})

if(USE_OBJLIB)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Right.

@koukou closed this in 89cc6b3Feb 25, 2022
@ursabot

ursabot commented Feb 25, 2022

Copy link
Copy Markdown

Benchmark runs are scheduled for baseline = acfd1d2 and contender = 89cc6b3. 89cc6b3 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Finished ⬇️0.21% ⬆️0.0%] test-mac-arm
[Finished ⬇️0.71% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️0.3% ⬆️0.0%] ursa-thinkcentre-m75q
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

marin-ma pushed a commit to marin-ma/arrow-1 that referenced this pull request Mar 28, 2022
…ine" build
This should fix:
- inline builds in general (ARROW-15709);
- [weird stuff with inline builds causing non-tracked files to be deleted](https://github.com/apache/arrow;/pull/12444#issuecomment-1043143303) that the [previous fix](apache#12444) for the above [caused](apache#12454)
- dependencies on git for downloading dependencies (ARROW-15760);
- the build process for Substrait previously being treated as something too special to use Arrow's normal method for dealing with third-party dependencies (i.e. `ThirdpartyToolchain.cmake`)
---
Initial attempt at making something functional to solve this issue properly.
The use of `add_arrow_lib` in `ThirdpartyToolchain.cmake` is certainly odd, and I'm sure I'm not following best practices in that file in general. I could use some advice on what the proper way to do this would be. Some of the issues:
- The CMake property specifying that a path refers to a generated file is scoped only to the current CMake file, so only moving the `externalproject_add` over to `ThirdpartyToolchain.cmake` resulted in the `add_arrow_lib` in `src/arrow/engine` failing due to missing source files. An object library didn't seem to resolve it either, and there are probably portability issues with that anyway, so that's why I ended up just using `add_arrow_lib`.
- Unlike all the other third-party dependencies (AFAICT), Substrait can't currently be installed, so `Substrait_SOURCE=SYSTEM` makes no sense. In the end I just decided to override it, but that's probably not ideal.
- Substrait doesn't have releases yet, so I had to resort to a git hash instead.
</details>
Closesapache#12457 from jvanstraten/ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi
Authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
(cherry picked from commit 89cc6b3)
zhouyuan pushed a commit to oap-project/arrow that referenced this pull request Apr 18, 2022
* ARROW-15238: [C++] ARROW_ENGINE module with substrait consumer
Continuation of apache#11707. I'm taking over from @bkietz for now because he's unavailable right now for personal reasons.
Closesapache#12279 from jvanstraten/substrait-consumer
Lead-authored-by: Benjamin Kietzman <bengilgit@gmail.com>
Co-authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Co-authored-by: Weston Pace <weston.pace@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
* ARROW-15700: [C++] Compilation error on Ubuntu 18.04
Modified Substrait consumer interaction with libprotobuf to support versions down to 3.0.0, which is the minimum required due to Substrait's usage of proto3 syntax.
Tested locally with:
```
export ARROW_PROTOBUF_URL=https://github.com/protocolbuffers/protobuf/releases/download/v3.0.0/protobuf-cpp-3.0.0.tar.gz
cmake \
--preset ninja-debug \
-DProtobuf_SOURCE=BUNDLED \
-DARROW_PROTOBUF_BUILD_VERSION=v3.0.0 \
-DARROW_PROTOBUF_BUILD_SHA256_CHECKSUM=318e8f375fb4e5333975a40e0d1215e855b4a8c581d692eb0eb7df70db1a8d4e
```
(Is there an easier way to do this without modifying versions.txt or 751fb9d? Also, the env var is needed only because Google isn't at all consistent with their release file naming that far back.)
It'd also be nice to add this to CI, but it's probably excessive to always run for a PR, unless combined with some other run.
Closesapache#12448 from jvanstraten/ARROW-15700-Compilation-error-on-Ubuntu-18-04
Authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
(cherry picked from commit 7d16a78)
* ARROW-15258: [C++] Easy options to create a source node from a table
This PR includes the addition of `TableSourceNode` to create a `ExecNode` easily using a table as the data source.
### TODO
- [x] Fix test case for chunk_size
Closesapache#12267 from vibhatha/arrow-15258-rb
Authored-by: Vibhatha Abeykoon <vibhatha@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
(cherry picked from commit fffdca2)
* ARROW-15709: [C++] Compilation of ARROW_ENGINE fails if doing an "inline" build
This should fix:
- inline builds in general (ARROW-15709);
- [weird stuff with inline builds causing non-tracked files to be deleted](https://github.com/apache/arrow;/pull/12444#issuecomment-1043143303) that the [previous fix](apache#12444) for the above [caused](apache#12454)
- dependencies on git for downloading dependencies (ARROW-15760);
- the build process for Substrait previously being treated as something too special to use Arrow's normal method for dealing with third-party dependencies (i.e. `ThirdpartyToolchain.cmake`)
---
Initial attempt at making something functional to solve this issue properly.
The use of `add_arrow_lib` in `ThirdpartyToolchain.cmake` is certainly odd, and I'm sure I'm not following best practices in that file in general. I could use some advice on what the proper way to do this would be. Some of the issues:
- The CMake property specifying that a path refers to a generated file is scoped only to the current CMake file, so only moving the `externalproject_add` over to `ThirdpartyToolchain.cmake` resulted in the `add_arrow_lib` in `src/arrow/engine` failing due to missing source files. An object library didn't seem to resolve it either, and there are probably portability issues with that anyway, so that's why I ended up just using `add_arrow_lib`.
- Unlike all the other third-party dependencies (AFAICT), Substrait can't currently be installed, so `Substrait_SOURCE=SYSTEM` makes no sense. In the end I just decided to override it, but that's probably not ideal.
- Substrait doesn't have releases yet, so I had to resort to a git hash instead.
</details>
Closesapache#12457 from jvanstraten/ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi
Authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
(cherry picked from commit 89cc6b3)
* ARROW-15830: [C++] Ensure target directory exists before running Substrait generation
Closesapache#12548 from pitrou/ARROW-15830-ubuntu-cpp-bundled
Authored-by: Antoine Pitrou <antoine@python.org>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
(cherry picked from commit e989fb3)
* ARROW-15850: [C++] Engine substrait headers missing from install
Closesapache#12569 from westonpace/feature/ARROW-15850--substrait-headers-missing
Authored-by: Weston Pace <weston.pace@gmail.com>
Signed-off-by: David Li <li.davidm96@gmail.com>
(cherry picked from commit 8fce593)
* Enable TPCH Q6 & Q1
Co-authored-by: Benjamin Kietzman <bengilgit@gmail.com>
Co-authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Co-authored-by: Weston Pace <weston.pace@gmail.com>
Co-authored-by: Vibhatha Abeykoon <vibhatha@gmail.com>
Co-authored-by: Antoine Pitrou <antoine@python.org>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@jvanstraten@westonpace@kou@pitrou@ursabot
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

ARROW-15709: [C++] Compilation of ARROW_ENGINE fails if doing an "inline" build - #12457

Closed
jvanstraten wants to merge 11 commits into
apache:masterfrom
jvanstraten:ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi
Closed

ARROW-15709: [C++] Compilation of ARROW_ENGINE fails if doing an "inline" build#12457
jvanstraten wants to merge 11 commits into
apache:masterfrom
jvanstraten:ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi

Conversation

@jvanstraten

@jvanstratenjvanstraten commented Feb 17, 2022

Copy link
Copy Markdown
Contributor

This should fix:


Initial attempt at making something functional to solve this issue properly.

The use of add_arrow_lib in ThirdpartyToolchain.cmake is certainly odd, and I'm sure I'm not following best practices in that file in general. I could use some advice on what the proper way to do this would be. Some of the issues:

  • The CMake property specifying that a path refers to a generated file is scoped only to the current CMake file, so only moving the externalproject_add over to ThirdpartyToolchain.cmake resulted in the add_arrow_lib in src/arrow/engine failing due to missing source files. An object library didn't seem to resolve it either, and there are probably portability issues with that anyway, so that's why I ended up just using add_arrow_lib.
  • Unlike all the other third-party dependencies (AFAICT), Substrait can't currently be installed, so Substrait_SOURCE=SYSTEM makes no sense. In the end I just decided to override it, but that's probably not ideal.
  • Substrait doesn't have releases yet, so I had to resort to a git hash instead.

@github-actions

Copy link
Copy Markdown

@westonpace

Copy link
Copy Markdown
Member

@kou@pitrou We could use input on this approach. The Substrait integration is a little unique because the .proto files themselves are not owned by us. We could fork a copy of the proto files but that would make keeping up with updated versions a bit tricky.

Protobuf is also a bit tricky because the version of the code generation tool (protoc) must match the version of the linked protobuf library exactly (this is different from flatbuffers which doesn't require a runtime dependency).

Previously we were downloading the proto files using git and running protoc within the engine directory. This had some negative side effects (#12454) mainly due to our use of git. Even beyond git however it was rather strange that this was resulting in a call to externalproject_add outside of ThirdPartyToolchain.cmake so @jvanstraten and I agreed it might be clear to treat Substrait as a "build-from-source only" third party dependency. This PR is @jvanstraten 's attempt to make that work but it is also odd as it requires a call to add_arrow_lib inside of ThirdPartyToolchain.cmake.

Any suggestions on a better approach or feedback on our current approach would be very much welcomed.

@jvanstraten
jvanstratenforce-pushed the ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi branch from a049bdd to fd6e5d4CompareFebruary 18, 2022 10:48
@kou

kou commented Feb 20, 2022

Copy link
Copy Markdown
Member

How about using just an OBJECT library https://cmake.org/cmake/help/latest/command/add_library.html#object-lib instead of arrow_add_lib()?

diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake
index 391c43e0ac..3afecfc562 100644
--- a/cpp/cmake_modules/BuildUtils.cmake+++ b/cpp/cmake_modules/BuildUtils.cmake@@ -297,6 +297,14 @@ function(ADD_ARROW_LIB LIB_NAME)
target_precompile_headers(${LIB_NAME}_objlib PRIVATE ${ARG_PRECOMPILED_HEADERS})
endif()
set(LIB_DEPS $<TARGET_OBJECTS:${LIB_NAME}_objlib>)
+ # We need to specify $<TARGET_OBJECTS:XXX> explicitly to SHARED+ # library and STATIC library because $<TARGET_OBJECTS:XXX> in+ # OBJECT isn't propagated to SHARED library and STATIC library.+ foreach(ARG_SOURCE ${ARG_SOURCES})+ if(ARG_SOURCE MATCHES "^\\$<TARGET_OBJECTS:")+ list(APPEND LIB_DEPS ${ARG_SOURCE})+ endif()+ endforeach()
set(LIB_INCLUDES)
set(EXTRA_DEPS)
diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index 8b53272452..9143550df9 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake@@ -1687,22 +1687,13 @@ macro(build_substrait)
add_custom_target(substrait_gen ALL DEPENDS ${SUBSTRAIT_PROTO_GEN_ALL})
- add_arrow_lib(arrow_substrait- SOURCES- ${SUBSTRAIT_SOURCES}- DEPENDENCIES- substrait_gen- SHARED_LINK_LIBS- ${ARROW_PROTOBUF_LIBPROTOBUF}- STATIC_LINK_LIBS- ${ARROW_PROTOBUF_LIBPROTOBUF}- PRIVATE_INCLUDES- ${SUBSTRAIT_CPP_DIR})-- set(SUBSTRAIT_DEPENDENCIES substrait_gen)- set(SUBSTRAIT_SHARED arrow_substrait_shared)- set(SUBSTRAIT_STATIC arrow_substrait_static)- set(SUBSTRAIT_INCLUDES ${SUBSTRAIT_CPP_DIR})+ add_library(substrait OBJECT ${SUBSTRAIT_SOURCES})+ set_target_properties(substrait+ PROPERTIES+ INCLUDE_DIRECTORIES ${SUBSTRAIT_CPP_DIR}+ POSITION_INDEPENDENT_CODE ON)+ add_dependencies(substrait substrait_gen)+ get_target_property(SUBSTRAIT_INCLUDES substrait INCLUDE_DIRECTORIES)
endmacro()
if(ARROW_WITH_SUBSTRAIT)
diff --git a/cpp/src/arrow/engine/CMakeLists.txt b/cpp/src/arrow/engine/CMakeLists.txt
index 50a84464c0..ff88f47e4a 100644
--- a/cpp/src/arrow/engine/CMakeLists.txt+++ b/cpp/src/arrow/engine/CMakeLists.txt@@ -36,9 +36,10 @@ add_arrow_lib(arrow_engine
OUTPUTS
ARROW_ENGINE_LIBRARIES
DEPENDENCIES
- ${SUBSTRAIT_DEPENDENCIES}+ substrait
SOURCES
${ARROW_ENGINE_SRCS}
+ $<TARGET_OBJECTS:substrait>
PRECOMPILED_HEADERS
"$<$<COMPILE_LANGUAGE:CXX>:arrow/engine/pch.h>"
SHARED_LINK_FLAGS
@@ -46,11 +47,9 @@ add_arrow_lib(arrow_engine
SHARED_LINK_LIBS
arrow_shared
arrow_dataset_shared
- ${SUBSTRAIT_SHARED}
STATIC_LINK_LIBS
arrow_static
arrow_dataset_static
- ${SUBSTRAIT_STATIC}
PRIVATE_INCLUDES
${SUBSTRAIT_INCLUDES})

@jvanstraten

Copy link
Copy Markdown
ContributorAuthor

@kou Thanks for the input! It's certainly a lot nicer to do it that way, but unfortunately, we're not quite there yet... I got it working in most build environments using your diff with some minor changes (had to add protobuf to the include list for the object library, and add its runtime library to arrow_engine), but it fails here:

CMake Error at cmake_modules/BuildUtils.cmake:287 (add_library):
OBJECT library "arrow_engine_objlib" contains:
capabilities.pb.cc.o
expression.pb.cc.o
extensions.pb.cc.o
function.pb.cc.o
parameterized_types.pb.cc.o
plan.pb.cc.o
relations.pb.cc.o
type.pb.cc.o
type_expressions.pb.cc.o
but may contain only sources that compile, header files, and other files
that would not affect linking of a normal library.

I feel like the addition to BuildUtils.cmake is either causing this or supposed to resolve this (and failing to do so in this particular case), but other than that, my skill level for CMake is insufficient to see what exactly is going on here.

set(SUBSTRAIT_SOURCE_URL "$ENV{ARROW_SUBSTRAIT_URL}")
else()
set_urls(SUBSTRAIT_SOURCE_URL
"https://github.com/substrait-io/substrait/archive/${ARROW_SUBSTRAIT_BUILD_VERSION}.tar.gz"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1, this will be much better than involving some git commands.

Comment threadcpp/src/arrow/engine/CMakeLists.txt Outdated
substrait
SOURCES
${ARROW_ENGINE_SRCS}
$<TARGET_OBJECTS:substrait>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm... is there a particular reason for this? Should we instead create a static library containing these objects? Or perhaps I'm entirely misunderstanding this?

@koukouFeb 21, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can use a static library instead of an object library without using add_arrow_lib(). We can just use raw add_library().

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Looks like that's working, 577979b. I wasn't sure how generally-applicable linking static libraries with -fPIC into shared libraries would be. I'm also not sure why I still need to specify PRIVATE_INCLUDES ${SUBSTRAIT_INCLUDES} for the add_arrow_lib call (shouldn't CMake be propagating public include directories to dependent libraries?), but I couldn't get it to work without it.

@jvanstraten
jvanstraten marked this pull request as ready for review February 22, 2022 18:27
# under the License.

# Currently, we can only build Substrait from source.
set(SUBSTRAIT_FOUND NO)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we remove this file?
It seems that this file is never used.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Comment threadcpp/src/arrow/engine/CMakeLists.txt Outdated
Comment on lines +38 to +39
DEPENDENCIES
substrait

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we remove this?
This will be automatically added by using substrait target.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

It doesn't build (multithreaded) without it. I think it ensures that substrait is built completely prior to compilation of arrow_engine, rather than just prior to linking, which matters because arrow_engine uses generated code. Making it depend on substrait_gen would also work, if you prefer that option (IMO, the less arrow_engine depends on implementation details of ThirdpartyToolchain.cmake the better, so I set it to just substrait).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems that this is a problem of our add_arrow_lib():

diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake
index 391c43e0ac..7517e4e806 100644
--- a/cpp/cmake_modules/BuildUtils.cmake+++ b/cpp/cmake_modules/BuildUtils.cmake@@ -374,6 +374,13 @@ function(ADD_ARROW_LIB LIB_NAME)
"$<INSTALL_INTERFACE:${ARG_SHARED_INSTALL_INTERFACE_LIBS}>"
LINK_PRIVATE
${ARG_SHARED_PRIVATE_LINK_LIBS})
+ if(USE_OBJLIB)+ foreach(ARG_SHARED_LINK_LIB ${ARG_SHARED_LINK_LIBS})+ if(TARGET ${ARG_SHARED_LINK_LIB})+ add_dependencies(${LIB_NAME}_objlib ${ARG_SHARED_LINK_LIB})+ endif()+ endforeach()+ endif()
if(ARROW_RPATH_ORIGIN)
if(APPLE)
@@ -449,6 +456,13 @@ function(ADD_ARROW_LIB LIB_NAME)
if(ARG_STATIC_LINK_LIBS)
target_link_libraries(${LIB_NAME}_static LINK_PRIVATE
"$<BUILD_INTERFACE:${ARG_STATIC_LINK_LIBS}>")
+ if(USE_OBJLIB)+ foreach(ARG_STATIC_LINK_LIB ${ARG_STATIC_LINK_LIBS})+ if(TARGET ${ARG_STATIC_LINK_LIB})+ add_dependencies(${LIB_NAME}_objlib ${ARG_STATIC_LINK_LIB})+ endif()+ endforeach()+ endif()
endif()
install(TARGETS ${LIB_NAME}_static ${INSTALL_IS_OPTIONAL}
diff --git a/cpp/src/arrow/engine/CMakeLists.txt b/cpp/src/arrow/engine/CMakeLists.txt
index 13d50b4244..edb878939f 100644
--- a/cpp/src/arrow/engine/CMakeLists.txt+++ b/cpp/src/arrow/engine/CMakeLists.txt@@ -35,8 +35,6 @@ add_arrow_lib(arrow_engine
arrow-engine
OUTPUTS
ARROW_ENGINE_LIBRARIES
- DEPENDENCIES- substrait
SOURCES
${ARROW_ENGINE_SRCS}
PRECOMPILED_HEADERS

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Okay, that fixes it on my end, too. fffa65c

set_target_properties(substrait PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(substrait PUBLIC ${SUBSTRAIT_INCLUDES})
target_link_libraries(substrait INTERFACE ${ARROW_PROTOBUF_LIBPROTOBUF})
add_dependencies(substrait substrait_gen)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you add substrait to ARROW_BUNDLED_STATIC_LIBS?

Suggested change
add_dependencies(substraitsubstrait_gen)
list(APPEND ARROW_BUNDLED_STATIC_LIBS substrait)

If we don't add this, users can't link to libarrow_engine.a statically with libarrow_bundled_dependencies.a.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Added in 3d7bac9

The removal of add_dependencies(substrait substrait_gen) seems unrelated. I suppose it's technically redundant, since CMake will generate the .cc files by way of needing them as input for compiling substrait, and the .h files just so happen to be generated by the same command. If for whatever reason only the generated .h files are removed though, CMake won't know to recreate them without that rule.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, sorry. It's my fault.

@jvanstraten

Copy link
Copy Markdown
ContributorAuthor

Failure of AMD64 Ubuntu 20.04 GLib & Ruby for
fffa65c seems to be unrelated (zlib download failure, I think). It builds correctly when I run it with archery locally.

@kou

kou commented Feb 23, 2022

Copy link
Copy Markdown
Member

@github-actions crossbow submit python-sdist

@github-actions

Copy link
Copy Markdown

Revision: fffa65c

Submitted crossbow builds: ursacomputing/crossbow @ actions-1676

TaskStatus
python-sdistGithub Actions

@jvanstraten

Copy link
Copy Markdown
ContributorAuthor

@kou@pitrou@westonpace I believe this is ready to be merged, or am I still missing something?

LINK_PRIVATE
${ARG_SHARED_PRIVATE_LINK_LIBS})

if(USE_OBJLIB)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add a comment explaining this snippet?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Added something in c2380ee. @kou, please verify if what I wrote for it is correct and complete.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Right.

Comment threadcpp/cmake_modules/BuildUtils.cmake Outdated
${ARG_SHARED_PRIVATE_LINK_LIBS})

if(USE_OBJLIB)
foreach(ARG_SHARED_LINK_LIB ${ARG_SHARED_LINK_LIBS})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor, but naming ARG_SOMETHING a variable that is not one of the original function arguments is confusing.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Comment on lines +1677 to +1681
add_custom_command(OUTPUT "${SUBSTRAIT_PROTO_GEN}.${EXT}"
COMMAND ${ARROW_PROTOBUF_PROTOC} "-I${SUBSTRAIT_LOCAL_DIR}/proto"
"--cpp_out=${SUBSTRAIT_CPP_DIR}"
"${SUBSTRAIT_LOCAL_DIR}/proto/substrait/${SUBSTRAIT_PROTO}.proto"
DEPENDS ${PROTO_DEPENDS} substrait_ep)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems like it compiles each proto file twice (once per extension)? Is that desired?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

No, probably not. I noticed it too when I inherited this code, but incorrectly assumed it was written like that because add_custom_command only supported a single output file. 7ad2e1f

@pitrou

Copy link
Copy Markdown
Member

Perhaps @kou can also double-check the CMake changes.

@westonpacewestonpace left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have nothing further to add. I think this looks much nicer than what we had before. We might try and take some snippets from here and push them upstream into the Substrait project's documentation in some kind of "getting started with C++" section.

kou
kou approved these changes Feb 25, 2022

@koukou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1

LINK_PRIVATE
${ARG_SHARED_PRIVATE_LINK_LIBS})

if(USE_OBJLIB)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Right.

@koukou closed this in 89cc6b3Feb 25, 2022
@ursabot

ursabot commented Feb 25, 2022

Copy link
Copy Markdown

Benchmark runs are scheduled for baseline = acfd1d2 and contender = 89cc6b3. 89cc6b3 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Finished ⬇️0.21% ⬆️0.0%] test-mac-arm
[Finished ⬇️0.71% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️0.3% ⬆️0.0%] ursa-thinkcentre-m75q
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

marin-ma pushed a commit to marin-ma/arrow-1 that referenced this pull request Mar 28, 2022
…ine" build
This should fix:
- inline builds in general (ARROW-15709);
- [weird stuff with inline builds causing non-tracked files to be deleted](https://github.com/apache/arrow;/pull/12444#issuecomment-1043143303) that the [previous fix](apache#12444) for the above [caused](apache#12454)
- dependencies on git for downloading dependencies (ARROW-15760);
- the build process for Substrait previously being treated as something too special to use Arrow's normal method for dealing with third-party dependencies (i.e. `ThirdpartyToolchain.cmake`)
---
Initial attempt at making something functional to solve this issue properly.
The use of `add_arrow_lib` in `ThirdpartyToolchain.cmake` is certainly odd, and I'm sure I'm not following best practices in that file in general. I could use some advice on what the proper way to do this would be. Some of the issues:
- The CMake property specifying that a path refers to a generated file is scoped only to the current CMake file, so only moving the `externalproject_add` over to `ThirdpartyToolchain.cmake` resulted in the `add_arrow_lib` in `src/arrow/engine` failing due to missing source files. An object library didn't seem to resolve it either, and there are probably portability issues with that anyway, so that's why I ended up just using `add_arrow_lib`.
- Unlike all the other third-party dependencies (AFAICT), Substrait can't currently be installed, so `Substrait_SOURCE=SYSTEM` makes no sense. In the end I just decided to override it, but that's probably not ideal.
- Substrait doesn't have releases yet, so I had to resort to a git hash instead.
</details>
Closesapache#12457 from jvanstraten/ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi
Authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
(cherry picked from commit 89cc6b3)
zhouyuan pushed a commit to oap-project/arrow that referenced this pull request Apr 18, 2022
* ARROW-15238: [C++] ARROW_ENGINE module with substrait consumer
Continuation of apache#11707. I'm taking over from @bkietz for now because he's unavailable right now for personal reasons.
Closesapache#12279 from jvanstraten/substrait-consumer
Lead-authored-by: Benjamin Kietzman <bengilgit@gmail.com>
Co-authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Co-authored-by: Weston Pace <weston.pace@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
* ARROW-15700: [C++] Compilation error on Ubuntu 18.04
Modified Substrait consumer interaction with libprotobuf to support versions down to 3.0.0, which is the minimum required due to Substrait's usage of proto3 syntax.
Tested locally with:
```
export ARROW_PROTOBUF_URL=https://github.com/protocolbuffers/protobuf/releases/download/v3.0.0/protobuf-cpp-3.0.0.tar.gz
cmake \
--preset ninja-debug \
-DProtobuf_SOURCE=BUNDLED \
-DARROW_PROTOBUF_BUILD_VERSION=v3.0.0 \
-DARROW_PROTOBUF_BUILD_SHA256_CHECKSUM=318e8f375fb4e5333975a40e0d1215e855b4a8c581d692eb0eb7df70db1a8d4e
```
(Is there an easier way to do this without modifying versions.txt or 751fb9d? Also, the env var is needed only because Google isn't at all consistent with their release file naming that far back.)
It'd also be nice to add this to CI, but it's probably excessive to always run for a PR, unless combined with some other run.
Closesapache#12448 from jvanstraten/ARROW-15700-Compilation-error-on-Ubuntu-18-04
Authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
(cherry picked from commit 7d16a78)
* ARROW-15258: [C++] Easy options to create a source node from a table
This PR includes the addition of `TableSourceNode` to create a `ExecNode` easily using a table as the data source.
### TODO
- [x] Fix test case for chunk_size
Closesapache#12267 from vibhatha/arrow-15258-rb
Authored-by: Vibhatha Abeykoon <vibhatha@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
(cherry picked from commit fffdca2)
* ARROW-15709: [C++] Compilation of ARROW_ENGINE fails if doing an "inline" build
This should fix:
- inline builds in general (ARROW-15709);
- [weird stuff with inline builds causing non-tracked files to be deleted](https://github.com/apache/arrow;/pull/12444#issuecomment-1043143303) that the [previous fix](apache#12444) for the above [caused](apache#12454)
- dependencies on git for downloading dependencies (ARROW-15760);
- the build process for Substrait previously being treated as something too special to use Arrow's normal method for dealing with third-party dependencies (i.e. `ThirdpartyToolchain.cmake`)
---
Initial attempt at making something functional to solve this issue properly.
The use of `add_arrow_lib` in `ThirdpartyToolchain.cmake` is certainly odd, and I'm sure I'm not following best practices in that file in general. I could use some advice on what the proper way to do this would be. Some of the issues:
- The CMake property specifying that a path refers to a generated file is scoped only to the current CMake file, so only moving the `externalproject_add` over to `ThirdpartyToolchain.cmake` resulted in the `add_arrow_lib` in `src/arrow/engine` failing due to missing source files. An object library didn't seem to resolve it either, and there are probably portability issues with that anyway, so that's why I ended up just using `add_arrow_lib`.
- Unlike all the other third-party dependencies (AFAICT), Substrait can't currently be installed, so `Substrait_SOURCE=SYSTEM` makes no sense. In the end I just decided to override it, but that's probably not ideal.
- Substrait doesn't have releases yet, so I had to resort to a git hash instead.
</details>
Closesapache#12457 from jvanstraten/ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi
Authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
(cherry picked from commit 89cc6b3)
* ARROW-15830: [C++] Ensure target directory exists before running Substrait generation
Closesapache#12548 from pitrou/ARROW-15830-ubuntu-cpp-bundled
Authored-by: Antoine Pitrou <antoine@python.org>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
(cherry picked from commit e989fb3)
* ARROW-15850: [C++] Engine substrait headers missing from install
Closesapache#12569 from westonpace/feature/ARROW-15850--substrait-headers-missing
Authored-by: Weston Pace <weston.pace@gmail.com>
Signed-off-by: David Li <li.davidm96@gmail.com>
(cherry picked from commit 8fce593)
* Enable TPCH Q6 & Q1
Co-authored-by: Benjamin Kietzman <bengilgit@gmail.com>
Co-authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Co-authored-by: Weston Pace <weston.pace@gmail.com>
Co-authored-by: Vibhatha Abeykoon <vibhatha@gmail.com>
Co-authored-by: Antoine Pitrou <antoine@python.org>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@jvanstraten@westonpace@kou@pitrou@ursabot
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

ARROW-15709: [C++] Compilation of ARROW_ENGINE fails if doing an "inline" build - #12457

Closed
jvanstraten wants to merge 11 commits into
apache:masterfrom
jvanstraten:ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi
Closed

ARROW-15709: [C++] Compilation of ARROW_ENGINE fails if doing an "inline" build#12457
jvanstraten wants to merge 11 commits into
apache:masterfrom
jvanstraten:ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi

Conversation

@jvanstraten

@jvanstratenjvanstraten commented Feb 17, 2022

Copy link
Copy Markdown
Contributor

This should fix:


Initial attempt at making something functional to solve this issue properly.

The use of add_arrow_lib in ThirdpartyToolchain.cmake is certainly odd, and I'm sure I'm not following best practices in that file in general. I could use some advice on what the proper way to do this would be. Some of the issues:

  • The CMake property specifying that a path refers to a generated file is scoped only to the current CMake file, so only moving the externalproject_add over to ThirdpartyToolchain.cmake resulted in the add_arrow_lib in src/arrow/engine failing due to missing source files. An object library didn't seem to resolve it either, and there are probably portability issues with that anyway, so that's why I ended up just using add_arrow_lib.
  • Unlike all the other third-party dependencies (AFAICT), Substrait can't currently be installed, so Substrait_SOURCE=SYSTEM makes no sense. In the end I just decided to override it, but that's probably not ideal.
  • Substrait doesn't have releases yet, so I had to resort to a git hash instead.

@github-actions

Copy link
Copy Markdown

@westonpace

Copy link
Copy Markdown
Member

@kou@pitrou We could use input on this approach. The Substrait integration is a little unique because the .proto files themselves are not owned by us. We could fork a copy of the proto files but that would make keeping up with updated versions a bit tricky.

Protobuf is also a bit tricky because the version of the code generation tool (protoc) must match the version of the linked protobuf library exactly (this is different from flatbuffers which doesn't require a runtime dependency).

Previously we were downloading the proto files using git and running protoc within the engine directory. This had some negative side effects (#12454) mainly due to our use of git. Even beyond git however it was rather strange that this was resulting in a call to externalproject_add outside of ThirdPartyToolchain.cmake so @jvanstraten and I agreed it might be clear to treat Substrait as a "build-from-source only" third party dependency. This PR is @jvanstraten 's attempt to make that work but it is also odd as it requires a call to add_arrow_lib inside of ThirdPartyToolchain.cmake.

Any suggestions on a better approach or feedback on our current approach would be very much welcomed.

@jvanstraten
jvanstratenforce-pushed the ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi branch from a049bdd to fd6e5d4CompareFebruary 18, 2022 10:48
@kou

kou commented Feb 20, 2022

Copy link
Copy Markdown
Member

How about using just an OBJECT library https://cmake.org/cmake/help/latest/command/add_library.html#object-lib instead of arrow_add_lib()?

diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake
index 391c43e0ac..3afecfc562 100644
--- a/cpp/cmake_modules/BuildUtils.cmake+++ b/cpp/cmake_modules/BuildUtils.cmake@@ -297,6 +297,14 @@ function(ADD_ARROW_LIB LIB_NAME)
target_precompile_headers(${LIB_NAME}_objlib PRIVATE ${ARG_PRECOMPILED_HEADERS})
endif()
set(LIB_DEPS $<TARGET_OBJECTS:${LIB_NAME}_objlib>)
+ # We need to specify $<TARGET_OBJECTS:XXX> explicitly to SHARED+ # library and STATIC library because $<TARGET_OBJECTS:XXX> in+ # OBJECT isn't propagated to SHARED library and STATIC library.+ foreach(ARG_SOURCE ${ARG_SOURCES})+ if(ARG_SOURCE MATCHES "^\\$<TARGET_OBJECTS:")+ list(APPEND LIB_DEPS ${ARG_SOURCE})+ endif()+ endforeach()
set(LIB_INCLUDES)
set(EXTRA_DEPS)
diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index 8b53272452..9143550df9 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake@@ -1687,22 +1687,13 @@ macro(build_substrait)
add_custom_target(substrait_gen ALL DEPENDS ${SUBSTRAIT_PROTO_GEN_ALL})
- add_arrow_lib(arrow_substrait- SOURCES- ${SUBSTRAIT_SOURCES}- DEPENDENCIES- substrait_gen- SHARED_LINK_LIBS- ${ARROW_PROTOBUF_LIBPROTOBUF}- STATIC_LINK_LIBS- ${ARROW_PROTOBUF_LIBPROTOBUF}- PRIVATE_INCLUDES- ${SUBSTRAIT_CPP_DIR})-- set(SUBSTRAIT_DEPENDENCIES substrait_gen)- set(SUBSTRAIT_SHARED arrow_substrait_shared)- set(SUBSTRAIT_STATIC arrow_substrait_static)- set(SUBSTRAIT_INCLUDES ${SUBSTRAIT_CPP_DIR})+ add_library(substrait OBJECT ${SUBSTRAIT_SOURCES})+ set_target_properties(substrait+ PROPERTIES+ INCLUDE_DIRECTORIES ${SUBSTRAIT_CPP_DIR}+ POSITION_INDEPENDENT_CODE ON)+ add_dependencies(substrait substrait_gen)+ get_target_property(SUBSTRAIT_INCLUDES substrait INCLUDE_DIRECTORIES)
endmacro()
if(ARROW_WITH_SUBSTRAIT)
diff --git a/cpp/src/arrow/engine/CMakeLists.txt b/cpp/src/arrow/engine/CMakeLists.txt
index 50a84464c0..ff88f47e4a 100644
--- a/cpp/src/arrow/engine/CMakeLists.txt+++ b/cpp/src/arrow/engine/CMakeLists.txt@@ -36,9 +36,10 @@ add_arrow_lib(arrow_engine
OUTPUTS
ARROW_ENGINE_LIBRARIES
DEPENDENCIES
- ${SUBSTRAIT_DEPENDENCIES}+ substrait
SOURCES
${ARROW_ENGINE_SRCS}
+ $<TARGET_OBJECTS:substrait>
PRECOMPILED_HEADERS
"$<$<COMPILE_LANGUAGE:CXX>:arrow/engine/pch.h>"
SHARED_LINK_FLAGS
@@ -46,11 +47,9 @@ add_arrow_lib(arrow_engine
SHARED_LINK_LIBS
arrow_shared
arrow_dataset_shared
- ${SUBSTRAIT_SHARED}
STATIC_LINK_LIBS
arrow_static
arrow_dataset_static
- ${SUBSTRAIT_STATIC}
PRIVATE_INCLUDES
${SUBSTRAIT_INCLUDES})

@jvanstraten

Copy link
Copy Markdown
ContributorAuthor

@kou Thanks for the input! It's certainly a lot nicer to do it that way, but unfortunately, we're not quite there yet... I got it working in most build environments using your diff with some minor changes (had to add protobuf to the include list for the object library, and add its runtime library to arrow_engine), but it fails here:

CMake Error at cmake_modules/BuildUtils.cmake:287 (add_library):
OBJECT library "arrow_engine_objlib" contains:
capabilities.pb.cc.o
expression.pb.cc.o
extensions.pb.cc.o
function.pb.cc.o
parameterized_types.pb.cc.o
plan.pb.cc.o
relations.pb.cc.o
type.pb.cc.o
type_expressions.pb.cc.o
but may contain only sources that compile, header files, and other files
that would not affect linking of a normal library.

I feel like the addition to BuildUtils.cmake is either causing this or supposed to resolve this (and failing to do so in this particular case), but other than that, my skill level for CMake is insufficient to see what exactly is going on here.

set(SUBSTRAIT_SOURCE_URL "$ENV{ARROW_SUBSTRAIT_URL}")
else()
set_urls(SUBSTRAIT_SOURCE_URL
"https://github.com/substrait-io/substrait/archive/${ARROW_SUBSTRAIT_BUILD_VERSION}.tar.gz"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1, this will be much better than involving some git commands.

Comment threadcpp/src/arrow/engine/CMakeLists.txt Outdated
substrait
SOURCES
${ARROW_ENGINE_SRCS}
$<TARGET_OBJECTS:substrait>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm... is there a particular reason for this? Should we instead create a static library containing these objects? Or perhaps I'm entirely misunderstanding this?

@koukouFeb 21, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can use a static library instead of an object library without using add_arrow_lib(). We can just use raw add_library().

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Looks like that's working, 577979b. I wasn't sure how generally-applicable linking static libraries with -fPIC into shared libraries would be. I'm also not sure why I still need to specify PRIVATE_INCLUDES ${SUBSTRAIT_INCLUDES} for the add_arrow_lib call (shouldn't CMake be propagating public include directories to dependent libraries?), but I couldn't get it to work without it.

@jvanstraten
jvanstraten marked this pull request as ready for review February 22, 2022 18:27
# under the License.

# Currently, we can only build Substrait from source.
set(SUBSTRAIT_FOUND NO)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we remove this file?
It seems that this file is never used.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Comment threadcpp/src/arrow/engine/CMakeLists.txt Outdated
Comment on lines +38 to +39
DEPENDENCIES
substrait

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we remove this?
This will be automatically added by using substrait target.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

It doesn't build (multithreaded) without it. I think it ensures that substrait is built completely prior to compilation of arrow_engine, rather than just prior to linking, which matters because arrow_engine uses generated code. Making it depend on substrait_gen would also work, if you prefer that option (IMO, the less arrow_engine depends on implementation details of ThirdpartyToolchain.cmake the better, so I set it to just substrait).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems that this is a problem of our add_arrow_lib():

diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake
index 391c43e0ac..7517e4e806 100644
--- a/cpp/cmake_modules/BuildUtils.cmake+++ b/cpp/cmake_modules/BuildUtils.cmake@@ -374,6 +374,13 @@ function(ADD_ARROW_LIB LIB_NAME)
"$<INSTALL_INTERFACE:${ARG_SHARED_INSTALL_INTERFACE_LIBS}>"
LINK_PRIVATE
${ARG_SHARED_PRIVATE_LINK_LIBS})
+ if(USE_OBJLIB)+ foreach(ARG_SHARED_LINK_LIB ${ARG_SHARED_LINK_LIBS})+ if(TARGET ${ARG_SHARED_LINK_LIB})+ add_dependencies(${LIB_NAME}_objlib ${ARG_SHARED_LINK_LIB})+ endif()+ endforeach()+ endif()
if(ARROW_RPATH_ORIGIN)
if(APPLE)
@@ -449,6 +456,13 @@ function(ADD_ARROW_LIB LIB_NAME)
if(ARG_STATIC_LINK_LIBS)
target_link_libraries(${LIB_NAME}_static LINK_PRIVATE
"$<BUILD_INTERFACE:${ARG_STATIC_LINK_LIBS}>")
+ if(USE_OBJLIB)+ foreach(ARG_STATIC_LINK_LIB ${ARG_STATIC_LINK_LIBS})+ if(TARGET ${ARG_STATIC_LINK_LIB})+ add_dependencies(${LIB_NAME}_objlib ${ARG_STATIC_LINK_LIB})+ endif()+ endforeach()+ endif()
endif()
install(TARGETS ${LIB_NAME}_static ${INSTALL_IS_OPTIONAL}
diff --git a/cpp/src/arrow/engine/CMakeLists.txt b/cpp/src/arrow/engine/CMakeLists.txt
index 13d50b4244..edb878939f 100644
--- a/cpp/src/arrow/engine/CMakeLists.txt+++ b/cpp/src/arrow/engine/CMakeLists.txt@@ -35,8 +35,6 @@ add_arrow_lib(arrow_engine
arrow-engine
OUTPUTS
ARROW_ENGINE_LIBRARIES
- DEPENDENCIES- substrait
SOURCES
${ARROW_ENGINE_SRCS}
PRECOMPILED_HEADERS

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Okay, that fixes it on my end, too. fffa65c

set_target_properties(substrait PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(substrait PUBLIC ${SUBSTRAIT_INCLUDES})
target_link_libraries(substrait INTERFACE ${ARROW_PROTOBUF_LIBPROTOBUF})
add_dependencies(substrait substrait_gen)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you add substrait to ARROW_BUNDLED_STATIC_LIBS?

Suggested change
add_dependencies(substraitsubstrait_gen)
list(APPEND ARROW_BUNDLED_STATIC_LIBS substrait)

If we don't add this, users can't link to libarrow_engine.a statically with libarrow_bundled_dependencies.a.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Added in 3d7bac9

The removal of add_dependencies(substrait substrait_gen) seems unrelated. I suppose it's technically redundant, since CMake will generate the .cc files by way of needing them as input for compiling substrait, and the .h files just so happen to be generated by the same command. If for whatever reason only the generated .h files are removed though, CMake won't know to recreate them without that rule.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, sorry. It's my fault.

@jvanstraten

Copy link
Copy Markdown
ContributorAuthor

Failure of AMD64 Ubuntu 20.04 GLib & Ruby for
fffa65c seems to be unrelated (zlib download failure, I think). It builds correctly when I run it with archery locally.

@kou

kou commented Feb 23, 2022

Copy link
Copy Markdown
Member

@github-actions crossbow submit python-sdist

@github-actions

Copy link
Copy Markdown

Revision: fffa65c

Submitted crossbow builds: ursacomputing/crossbow @ actions-1676

TaskStatus
python-sdistGithub Actions

@jvanstraten

Copy link
Copy Markdown
ContributorAuthor

@kou@pitrou@westonpace I believe this is ready to be merged, or am I still missing something?

LINK_PRIVATE
${ARG_SHARED_PRIVATE_LINK_LIBS})

if(USE_OBJLIB)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add a comment explaining this snippet?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Added something in c2380ee. @kou, please verify if what I wrote for it is correct and complete.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Right.

Comment threadcpp/cmake_modules/BuildUtils.cmake Outdated
${ARG_SHARED_PRIVATE_LINK_LIBS})

if(USE_OBJLIB)
foreach(ARG_SHARED_LINK_LIB ${ARG_SHARED_LINK_LIBS})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor, but naming ARG_SOMETHING a variable that is not one of the original function arguments is confusing.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Comment on lines +1677 to +1681
add_custom_command(OUTPUT "${SUBSTRAIT_PROTO_GEN}.${EXT}"
COMMAND ${ARROW_PROTOBUF_PROTOC} "-I${SUBSTRAIT_LOCAL_DIR}/proto"
"--cpp_out=${SUBSTRAIT_CPP_DIR}"
"${SUBSTRAIT_LOCAL_DIR}/proto/substrait/${SUBSTRAIT_PROTO}.proto"
DEPENDS ${PROTO_DEPENDS} substrait_ep)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems like it compiles each proto file twice (once per extension)? Is that desired?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

No, probably not. I noticed it too when I inherited this code, but incorrectly assumed it was written like that because add_custom_command only supported a single output file. 7ad2e1f

@pitrou

Copy link
Copy Markdown
Member

Perhaps @kou can also double-check the CMake changes.

@westonpacewestonpace left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have nothing further to add. I think this looks much nicer than what we had before. We might try and take some snippets from here and push them upstream into the Substrait project's documentation in some kind of "getting started with C++" section.

kou
kou approved these changes Feb 25, 2022

@koukou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1

LINK_PRIVATE
${ARG_SHARED_PRIVATE_LINK_LIBS})

if(USE_OBJLIB)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Right.

@koukou closed this in 89cc6b3Feb 25, 2022
@ursabot

ursabot commented Feb 25, 2022

Copy link
Copy Markdown

Benchmark runs are scheduled for baseline = acfd1d2 and contender = 89cc6b3. 89cc6b3 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Finished ⬇️0.21% ⬆️0.0%] test-mac-arm
[Finished ⬇️0.71% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️0.3% ⬆️0.0%] ursa-thinkcentre-m75q
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

marin-ma pushed a commit to marin-ma/arrow-1 that referenced this pull request Mar 28, 2022
…ine" build
This should fix:
- inline builds in general (ARROW-15709);
- [weird stuff with inline builds causing non-tracked files to be deleted](https://github.com/apache/arrow;/pull/12444#issuecomment-1043143303) that the [previous fix](apache#12444) for the above [caused](apache#12454)
- dependencies on git for downloading dependencies (ARROW-15760);
- the build process for Substrait previously being treated as something too special to use Arrow's normal method for dealing with third-party dependencies (i.e. `ThirdpartyToolchain.cmake`)
---
Initial attempt at making something functional to solve this issue properly.
The use of `add_arrow_lib` in `ThirdpartyToolchain.cmake` is certainly odd, and I'm sure I'm not following best practices in that file in general. I could use some advice on what the proper way to do this would be. Some of the issues:
- The CMake property specifying that a path refers to a generated file is scoped only to the current CMake file, so only moving the `externalproject_add` over to `ThirdpartyToolchain.cmake` resulted in the `add_arrow_lib` in `src/arrow/engine` failing due to missing source files. An object library didn't seem to resolve it either, and there are probably portability issues with that anyway, so that's why I ended up just using `add_arrow_lib`.
- Unlike all the other third-party dependencies (AFAICT), Substrait can't currently be installed, so `Substrait_SOURCE=SYSTEM` makes no sense. In the end I just decided to override it, but that's probably not ideal.
- Substrait doesn't have releases yet, so I had to resort to a git hash instead.
</details>
Closesapache#12457 from jvanstraten/ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi
Authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
(cherry picked from commit 89cc6b3)
zhouyuan pushed a commit to oap-project/arrow that referenced this pull request Apr 18, 2022
* ARROW-15238: [C++] ARROW_ENGINE module with substrait consumer
Continuation of apache#11707. I'm taking over from @bkietz for now because he's unavailable right now for personal reasons.
Closesapache#12279 from jvanstraten/substrait-consumer
Lead-authored-by: Benjamin Kietzman <bengilgit@gmail.com>
Co-authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Co-authored-by: Weston Pace <weston.pace@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
* ARROW-15700: [C++] Compilation error on Ubuntu 18.04
Modified Substrait consumer interaction with libprotobuf to support versions down to 3.0.0, which is the minimum required due to Substrait's usage of proto3 syntax.
Tested locally with:
```
export ARROW_PROTOBUF_URL=https://github.com/protocolbuffers/protobuf/releases/download/v3.0.0/protobuf-cpp-3.0.0.tar.gz
cmake \
--preset ninja-debug \
-DProtobuf_SOURCE=BUNDLED \
-DARROW_PROTOBUF_BUILD_VERSION=v3.0.0 \
-DARROW_PROTOBUF_BUILD_SHA256_CHECKSUM=318e8f375fb4e5333975a40e0d1215e855b4a8c581d692eb0eb7df70db1a8d4e
```
(Is there an easier way to do this without modifying versions.txt or 751fb9d? Also, the env var is needed only because Google isn't at all consistent with their release file naming that far back.)
It'd also be nice to add this to CI, but it's probably excessive to always run for a PR, unless combined with some other run.
Closesapache#12448 from jvanstraten/ARROW-15700-Compilation-error-on-Ubuntu-18-04
Authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
(cherry picked from commit 7d16a78)
* ARROW-15258: [C++] Easy options to create a source node from a table
This PR includes the addition of `TableSourceNode` to create a `ExecNode` easily using a table as the data source.
### TODO
- [x] Fix test case for chunk_size
Closesapache#12267 from vibhatha/arrow-15258-rb
Authored-by: Vibhatha Abeykoon <vibhatha@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
(cherry picked from commit fffdca2)
* ARROW-15709: [C++] Compilation of ARROW_ENGINE fails if doing an "inline" build
This should fix:
- inline builds in general (ARROW-15709);
- [weird stuff with inline builds causing non-tracked files to be deleted](https://github.com/apache/arrow;/pull/12444#issuecomment-1043143303) that the [previous fix](apache#12444) for the above [caused](apache#12454)
- dependencies on git for downloading dependencies (ARROW-15760);
- the build process for Substrait previously being treated as something too special to use Arrow's normal method for dealing with third-party dependencies (i.e. `ThirdpartyToolchain.cmake`)
---
Initial attempt at making something functional to solve this issue properly.
The use of `add_arrow_lib` in `ThirdpartyToolchain.cmake` is certainly odd, and I'm sure I'm not following best practices in that file in general. I could use some advice on what the proper way to do this would be. Some of the issues:
- The CMake property specifying that a path refers to a generated file is scoped only to the current CMake file, so only moving the `externalproject_add` over to `ThirdpartyToolchain.cmake` resulted in the `add_arrow_lib` in `src/arrow/engine` failing due to missing source files. An object library didn't seem to resolve it either, and there are probably portability issues with that anyway, so that's why I ended up just using `add_arrow_lib`.
- Unlike all the other third-party dependencies (AFAICT), Substrait can't currently be installed, so `Substrait_SOURCE=SYSTEM` makes no sense. In the end I just decided to override it, but that's probably not ideal.
- Substrait doesn't have releases yet, so I had to resort to a git hash instead.
</details>
Closesapache#12457 from jvanstraten/ARROW-15709-Compilation-of-ARROW-ENGINE-fails-if-doi
Authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
(cherry picked from commit 89cc6b3)
* ARROW-15830: [C++] Ensure target directory exists before running Substrait generation
Closesapache#12548 from pitrou/ARROW-15830-ubuntu-cpp-bundled
Authored-by: Antoine Pitrou <antoine@python.org>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
(cherry picked from commit e989fb3)
* ARROW-15850: [C++] Engine substrait headers missing from install
Closesapache#12569 from westonpace/feature/ARROW-15850--substrait-headers-missing
Authored-by: Weston Pace <weston.pace@gmail.com>
Signed-off-by: David Li <li.davidm96@gmail.com>
(cherry picked from commit 8fce593)
* Enable TPCH Q6 & Q1
Co-authored-by: Benjamin Kietzman <bengilgit@gmail.com>
Co-authored-by: Jeroen van Straten <jeroen.van.straten@gmail.com>
Co-authored-by: Weston Pace <weston.pace@gmail.com>
Co-authored-by: Vibhatha Abeykoon <vibhatha@gmail.com>
Co-authored-by: Antoine Pitrou <antoine@python.org>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@jvanstraten@westonpace@kou@pitrou@ursabot