You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "felipecrv (via GitHub)" <gi...@apache.org> on 2024/03/18 15:56:34 UTC
[I] [C++] Both on -O2 and -O3 passed when building with clang [arrow]
felipecrv opened a new issue, #40635:
URL: https://github.com/apache/arrow/issues/40635
### Describe the bug, including details regarding any error messages, version, and platform.
I configured a release build on macOS with the following shell script:
```sh
#!/bin/sh
cmake -G Ninja $1 \
-DCMAKE_BUILD_TYPE="Release" \
-DARROW_BUILD_BENCHMARKS=ON \
-DARROW_BUILD_STATIC=ON \
-DARROW_BUILD_SHARED=ON \
-DARROW_BUILD_TESTS=ON \
-DARROW_ENABLE_TIMING_TESTS=ON \
-DARROW_ACERO=ON \
-DARROW_AZURE=ON \
-DARROW_COMPUTE=ON \
-DARROW_DATASET=ON \
-DARROW_FILESYSTEM=ON \
-DARROW_GCS=OFF \
-DARROW_IPC=ON \
-DARROW_JEMALLOC=ON \
-DARROW_JSON=ON \
-DARROW_PARQUET=ON \
-DARROW_TESTING=ON \
-DARROW_BENCHMARKS=ON
```
Building a specific target with `ninja -v` I see both `-O2` and `-O3` flags
```sh
ninja -v ./src/arrow/CMakeFiles/arrow_compute.dir/compute/kernels/vector_selection_take_internal.cc.o
[1/1] /opt/homebrew/bin/ccache /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DARROW_HAVE_NEON -DARROW_WITH_TIMING_TESTS -I/Users/felipe/code/arrow/cpp/release/src -I/Users/felipe/code/arrow/cpp/src -I/Users/felipe/code/arrow/cpp/src/generated -isystem /opt/homebrew/include -fno-aligned-new -Qunused-arguments -fcolor-diagnostics -Wall -Wno-unknown-warning-option -Wno-pas
s-failed -march=armv8-a -O3 -DNDEBUG -O2 -std=c++17 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -fPIC -MD -MT src/arrow/CMakeFiles/arrow_compute.dir/compute/kernels/vector_selection_take_internal.cc.o -MF src/arrow/CMakeFiles/arrow_compute.dir/compute/kernels/vector_selection_take_internal.cc.o.d -o src/arrow/CMakeFiles/arrow_compute.dir/c
ompute/kernels/vector_selection_take_internal.cc.o -c /Users/felipe/code/arrow/cpp/src/arrow/compute/kernels/vector_selection_take_internal.cc
```
When both `-O2` and `-O3` are passed, `clang` picks the higher level of optimization — `-O3`. But is that really the intention of the build given that `-O2` is also being passed?
### Component(s)
C++
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@arrow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [C++] Both on -O2 and -O3 passed when building with clang [arrow]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on issue #40635:
URL: https://github.com/apache/arrow/issues/40635#issuecomment-2005307971
Passing `-O2` and `-O3` is intentional. We want to use `-O2` instead of `-O3`. Appending `-O2` is safer operation than replacing options string. (e.g. If we use replacing, we need to support `"-O3"`/`"... -O3"`/`"-O3 ..."`/... cases.)
> When both `-O2` and `-O3` are passed, `clang` picks the higher level of optimization — `-O3`.
Really? It seems that the later flag is used:
```console
$ clang xxx.c -O3 && ls -la a.out
-rwxr-xr-x 1 kou kou 16048 Mar 19 08:33 a.out
$ clang xxx.c -O0 && ls -la a.out
-rwxr-xr-x 1 kou kou 16080 Mar 19 08:33 a.out
$ clang xxx.c -O0 -O3 $$ ls -la a.out
-rwxr-xr-x 1 kou kou 16048 Mar 19 08:34 a.out
$ clang xxx.c -O3 -O0 && ls -la a.out
-rwxr-xr-x 1 kou kou 16080 Mar 19 08:34 a.out
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [C++] Both on -O2 and -O3 passed when building with clang [arrow]
Posted by "assignUser (via GitHub)" <gi...@apache.org>.
assignUser commented on issue #40635:
URL: https://github.com/apache/arrow/issues/40635#issuecomment-2004441924
Seems to be the opposite of what is supposed to happen?
https://github.com/apache/arrow/blob/98a0fc85709970e3270c2dd29ef077d60fa10f74/cpp/cmake_modules/SetupCxxFlags.cmake#L659-L660
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [C++] Both on -O2 and -O3 passed when building with clang [arrow]
Posted by "felipecrv (via GitHub)" <gi...@apache.org>.
felipecrv commented on issue #40635:
URL: https://github.com/apache/arrow/issues/40635#issuecomment-2005352682
My bad. I must have read some LLM hallucination about -O3 overriding -O2 (it made sense!).
I'm closing this since -O2 is the intention and -O2 is what we are getting.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [C++] Both on -O2 and -O3 passed when building with clang [arrow]
Posted by "assignUser (via GitHub)" <gi...@apache.org>.
assignUser commented on issue #40635:
URL: https://github.com/apache/arrow/issues/40635#issuecomment-2005334535
> the later flag is used
[This was also my understanding](https://stackoverflow.com/questions/5557261/gcc-multiple-optimization-flags)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [C++] Both on -O2 and -O3 passed when building with clang [arrow]
Posted by "felipecrv (via GitHub)" <gi...@apache.org>.
felipecrv closed issue #40635: [C++] Both on -O2 and -O3 passed when building with clang
URL: https://github.com/apache/arrow/issues/40635
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org