Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[C++] ARROW_BUILD_SHARED=OFF and ARROW_BUILD_EXAMPLES=ON causes build error #33849

Closed
kou opened this issue Jan 24, 2023 · 6 comments · Fixed by #34350
Closed

[C++] ARROW_BUILD_SHARED=OFF and ARROW_BUILD_EXAMPLES=ON causes build error #33849

kou opened this issue Jan 24, 2023 · 6 comments · Fixed by #34350
Assignees
Milestone

Comments

@kou
Copy link
Member

kou commented Jan 24, 2023

Describe the bug, including details regarding any error messages, version, and platform.

cpp/examples/arrow/CMakeLists.txt uses arrow_substrait_shared and gandiva_shared unconditionally. We can't use them with ARROW_BUILD_SHARED=OFF.

The following patch may fix this:

diff --git a/cpp/examples/arrow/CMakeLists.txt b/cpp/examples/arrow/CMakeLists.txt
index aa33c18e76..56371c0446 100644
--- a/cpp/examples/arrow/CMakeLists.txt
+++ b/cpp/examples/arrow/CMakeLists.txt
@@ -24,7 +24,13 @@ if(ARROW_COMPUTE)
 endif()
 
 if(ARROW_SUBSTRAIT)
-  add_arrow_example(engine_substrait_consumption EXTRA_LINK_LIBS arrow_substrait_shared)
+  if(ARROW_BUILD_SHARED)
+    set(ENGINE_SUBSTRAIT_CONSUMPTION_LINK_LIBS arrow_substrait_shared)
+  else()
+    set(ENGINE_SUBSTRAIT_CONSUMPTION_LINK_LIBS arrow_substrait_static)
+  endif()
+  add_arrow_example(engine_substrait_consumption EXTRA_LINK_LIBS
+                    ${ENGINE_SUBSTRAIT_CONSUMPTION_LINK_LIBS})
 endif()
 
 if(ARROW_COMPUTE AND ARROW_CSV)
@@ -167,5 +173,10 @@ if(ARROW_PARQUET AND ARROW_DATASET)
 endif()
 
 if(ARROW_GANDIVA)
-  add_arrow_example(gandiva_example EXTRA_LINK_LIBS gandiva_shared)
+  if(ARROW_BUILD_SHARED)
+    set(GANDIVA_EXAMPLE_LINK_LIBS gandiva_shared)
+  else()
+    set(GANDIVA_EXAMPLE_LINK_LIBS gandiva_static)
+  endif()
+  add_arrow_example(gandiva_example EXTRA_LINK_LIBS ${GANDIVA_EXAMPLE_LINK_LIBS})
 endif()

Component(s)

C++

@abetomo
Copy link
Contributor

abetomo commented Feb 8, 2023

take

@abetomo
Copy link
Contributor

abetomo commented Feb 20, 2023

Executed command:

$ cmake .. --preset ninja-debug-maximal -DARROW_BUILD_SHARED=OFF -DARROW_BUILD_STATIC=ON
$ cmake --build .

Errors

/usr/bin/ld: cannot find -larrow_substrait_shared: No such file or directory
collect2: error: ld returned 1 exit status

@kou
Copy link
Member Author

kou commented Feb 21, 2023

Could you show full error log?

@abetomo
Copy link
Contributor

abetomo commented Feb 21, 2023

The full error log is this.

$ cmake --build .
[4/23] Linking CXX executable debug/engine-substrait-consumption
FAILED: debug/engine-substrait-consumption
: && /usr/bin/c++ -Wno-noexcept-type  -fdiagnostics-color=always  -Wall -Wno-conversion -Wno-sign-conversion -Wunused-result -fno-semantic-interposition -msse4.2  -g -Werror -O0 -ggdb  examples/arrow/CMakeFiles/engine-substrait-consumption.dir/engine_substrait_consumption.cc.o -o debug/engine-substrait-consumption  debug/libarrow.a  -larrow_substrait_shared  brotli_ep/src/brotli_ep-install/lib/libbrotlienc-static.a  brotli_ep/src/brotli_ep-install/lib/libbrotlidec-static.a  brotli_ep/src/brotli_ep-install/lib/libbrotlicommon-static.a  bzip2_ep-install/lib/libbz2.a  orc_ep-install/lib/liborc.a  lz4_ep-install/lib/liblz4.a  snappy_ep/src/snappy_ep-install/lib/libsnappy.a  zstd_ep-install/lib/libzstd.a  protobuf_ep-install/lib/libprotobuf.a  google_cloud_cpp_ep-install/lib/libgoogle_cloud_cpp_storage.a  /usr/lib/x86_64-linux-gnu/libz.so  google_cloud_cpp_ep-install/lib/libgoogle_cloud_cpp_rest_internal.a  google_cloud_cpp_ep-install/lib/libgoogle_cloud_cpp_common.a  absl_ep-install/lib/libabsl_bad_optional_access.a  absl_ep-install/lib/libabsl_str_format_internal.a  absl_ep-install/lib/libabsl_time.a  absl_ep-install/lib/libabsl_strings.a  absl_ep-install/lib/libabsl_strings_internal.a  absl_ep-install/lib/libabsl_throw_delegate.a  absl_ep-install/lib/libabsl_base.a  absl_ep-install/lib/libabsl_spinlock_wait.a  absl_ep-install/lib/libabsl_int128.a  absl_ep-install/lib/libabsl_civil_time.a  absl_ep-install/lib/libabsl_time_zone.a  absl_ep-install/lib/libabsl_bad_variant_access.a  absl_ep-install/lib/libabsl_raw_logging_internal.a  absl_ep-install/lib/libabsl_log_severity.a  crc32c_ep-install/lib/libcrc32c.a  awssdk_ep-install/lib/libaws-cpp-sdk-identity-management.a  awssdk_ep-install/lib/libaws-cpp-sdk-sts.a  awssdk_ep-install/lib/libaws-cpp-sdk-cognito-identity.a  awssdk_ep-install/lib/libaws-cpp-sdk-s3.a  awssdk_ep-install/lib/libaws-cpp-sdk-core.a  /usr/lib/x86_64-linux-gnu/libcurl.so  awssdk_ep-install/lib/libaws-crt-cpp.a  awssdk_ep-install/lib/libaws-c-s3.a  awssdk_ep-install/lib/libaws-c-auth.a  awssdk_ep-install/lib/libaws-c-mqtt.a  awssdk_ep-install/lib/libaws-c-http.a  awssdk_ep-install/lib/libaws-c-compression.a  awssdk_ep-install/lib/libaws-c-sdkutils.a  awssdk_ep-install/lib/libaws-c-event-stream.a  awssdk_ep-install/lib/libaws-c-io.a  awssdk_ep-install/lib/libaws-c-cal.a  /usr/lib/x86_64-linux-gnu/libssl.so  /usr/lib/x86_64-linux-gnu/libcrypto.so  awssdk_ep-install/lib/libaws-checksums.a  awssdk_ep-install/lib/libaws-c-common.a  awssdk_ep-install/lib/libs2n.a  utf8proc_ep-install/lib/libutf8proc.a  re2_ep-install/lib/libre2.a  -ldl  jemalloc_ep-prefix/src/jemalloc_ep/dist//lib/libjemalloc_pic.a  mimalloc_ep/src/mimalloc_ep/lib/mimalloc-2.0/libmimalloc-debug.a  -lrt && :
/usr/bin/ld: cannot find -larrow_substrait_shared: No such file or directory
collect2: error: ld returned 1 exit status
[6/23] Bundling /home/xxx/arrow/cpp/build/debug/libarrow_bundled_dependencies.a
ninja: build stopped: subcommand failed.

@kou
Copy link
Member Author

kou commented Feb 21, 2023

Thanks. This is reproduced.

abetomo added a commit to abetomo/arrow that referenced this issue Feb 25, 2023
…W_BUILD_EXAMPLES=ON

Signed-off-by: abetomo <abe@enzou.tokyo>
@abetomo
Copy link
Contributor

abetomo commented Feb 25, 2023

Build with only patches related to ARROW_SUBSTRAIT applied.
The following error.

$ cmake --build .
[4/5] Linking CXX executable debug/gandiva-example
FAILED: debug/gandiva-example
: && /usr/bin/c++ -Wno-noexcept-type  -fdiagnostics-color=always  -Wall -Wno-conversion -Wno-sign-conversion -Wunused-result -fno-semantic-interposition -msse4.2  -g -Werror -O0 -ggdb  examples/arrow/CMakeFiles/gandiva-example.dir/gandiva_example.cc.o -o debug/gandiva-example  debug/libarrow.a  -lgandiva_shared  brotli_ep/src/brotli_ep-install/lib/libbrotlienc-static.a  brotli_ep/src/brotli_ep-install/lib/libbrotlidec-static.a  brotli_ep/src/brotli_ep-install/lib/libbrotlicommon-static.a  /usr/lib/x86_64-linux-gnu/libbz2.so  orc_ep-install/lib/liborc.a  lz4_ep-install/lib/liblz4.a  snappy_ep/src/snappy_ep-install/lib/libsnappy.a  zstd_ep-install/lib/libzstd.a  protobuf_ep-install/lib/libprotobuf.a  google_cloud_cpp_ep-install/lib/libgoogle_cloud_cpp_storage.a  /usr/lib/x86_64-linux-gnu/libz.so  google_cloud_cpp_ep-install/lib/libgoogle_cloud_cpp_rest_internal.a  google_cloud_cpp_ep-install/lib/libgoogle_cloud_cpp_common.a  absl_ep-install/lib/libabsl_bad_optional_access.a  absl_ep-install/lib/libabsl_str_format_internal.a  absl_ep-install/lib/libabsl_time.a  absl_ep-install/lib/libabsl_strings.a  absl_ep-install/lib/libabsl_strings_internal.a  absl_ep-install/lib/libabsl_throw_delegate.a  absl_ep-install/lib/libabsl_base.a  absl_ep-install/lib/libabsl_spinlock_wait.a  absl_ep-install/lib/libabsl_int128.a  absl_ep-install/lib/libabsl_civil_time.a  absl_ep-install/lib/libabsl_time_zone.a  absl_ep-install/lib/libabsl_bad_variant_access.a  absl_ep-install/lib/libabsl_raw_logging_internal.a  absl_ep-install/lib/libabsl_log_severity.a  crc32c_ep-install/lib/libcrc32c.a  awssdk_ep-install/lib/libaws-cpp-sdk-identity-management.a  awssdk_ep-install/lib/libaws-cpp-sdk-sts.a  awssdk_ep-install/lib/libaws-cpp-sdk-cognito-identity.a  awssdk_ep-install/lib/libaws-cpp-sdk-s3.a  awssdk_ep-install/lib/libaws-cpp-sdk-core.a  /usr/lib/x86_64-linux-gnu/libcurl.so  awssdk_ep-install/lib/libaws-crt-cpp.a  awssdk_ep-install/lib/libaws-c-s3.a  awssdk_ep-install/lib/libaws-c-auth.a  awssdk_ep-install/lib/libaws-c-mqtt.a  awssdk_ep-install/lib/libaws-c-http.a  awssdk_ep-install/lib/libaws-c-compression.a  awssdk_ep-install/lib/libaws-c-sdkutils.a  awssdk_ep-install/lib/libaws-c-event-stream.a  awssdk_ep-install/lib/libaws-c-io.a  awssdk_ep-install/lib/libaws-c-cal.a  /usr/lib/x86_64-linux-gnu/libssl.so  /usr/lib/x86_64-linux-gnu/libcrypto.so  awssdk_ep-install/lib/libaws-checksums.a  awssdk_ep-install/lib/libaws-c-common.a  awssdk_ep-install/lib/libs2n.a  utf8proc_ep-install/lib/libutf8proc.a  re2_ep-install/lib/libre2.a  -ldl  jemalloc_ep-prefix/src/jemalloc_ep/dist//lib/libjemalloc_pic.a  mimalloc_ep/src/mimalloc_ep/lib/mimalloc-2.0/libmimalloc-debug.a  -lrt && :
/usr/bin/ld: cannot find -lgandiva_shared: No such file or directory
collect2: error: ld returned 1 exit status
[5/5] Bundling /home/vagrant/work/arrow/cpp/build/debug/libarrow_bundled_dependencies.a
ninja: build stopped: subcommand failed.

abetomo added a commit to abetomo/arrow that referenced this issue Mar 12, 2023
…W_BUILD_EXAMPLES=ON

Signed-off-by: abetomo <abe@enzou.tokyo>
abetomo added a commit to abetomo/arrow that referenced this issue Mar 12, 2023
…_SHARED=OFF

Signed-off-by: abetomo <abe@enzou.tokyo>
@kou kou added this to the 12.0.0 milestone Mar 13, 2023
kou pushed a commit that referenced this issue Mar 13, 2023
…D_EXAMPLES=ON (#34350)

### Rationale for this change

Building with `ARROW_BUILD_SHARED=OFF` and `ARROW_BUILD_EXAMPLES=ON` causes an error.

### What changes are included in this PR?

At `examples/arrow/CMakeLists.txt`, set `arrow_substrait_[shared|static]` and `gandiva_[shared|static]` appropriately according to `ARROW_BUILD_SHARED`.

### Are these changes tested?

In `--preset ninja-debug-maximal`, `ARROW_BUILD_EXAMPLES=ON`.

```
$ cmake .. --preset ninja-debug-maximal -DARROW_BUILD_SHARED=OFF -DARROW_BUILD_STATIC=ON
$ cmake --build .
```

Build was completed.

```
$ cmake .. --preset ninja-debug-maximal -DARROW_BUILD_SHARED=ON -DARROW_BUILD_STATIC=ON
$ cmake --build .
```

Build was completed.

### Are there any user-facing changes?

* Closes: #33849

Authored-by: abetomo <abe@enzou.tokyo>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants