From 59b3e5f2aaab271f6a9eb7f2ebfc90b750e2940e Mon Sep 17 00:00:00 2001 From: mhucka Date: Thu, 26 Mar 2026 21:53:57 +0000 Subject: [PATCH] Don't need to set `GLIBCXX_USE_CXX11_ABI` This environment variable is set in `.bazelrc`, so it is no longer necessary to add `-D_GLIBCXX_USE_CXX11_ABI=1` all over the place when running Bazel. --- benchmarks/README.md | 5 ++--- scripts/benchmark_all.sh | 12 ++++++------ scripts/build_pip_package_test.sh | 8 ++++---- scripts/msan_test.sh | 14 +++++++------- scripts/test_all.sh | 8 ++++---- scripts/test_benchmarks.sh | 14 +++++++------- 6 files changed, 30 insertions(+), 31 deletions(-) diff --git a/benchmarks/README.md b/benchmarks/README.md index 4e71f8de2..5ecbbfd23 100644 --- a/benchmarks/README.md +++ b/benchmarks/README.md @@ -24,7 +24,7 @@ Some notes on benchmark configuration: For example, to benchmark a dense depth-10 Clifford circuit over 5 qubits call: ``` -bazel run -c opt --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=1" --cxxopt="-msse2" \ +bazel run -c opt --cxxopt="-msse2" \ --cxxopt="-msse3" --cxxopt="-msse4" \ benchmarks/scripts:benchmark_clifford_circuit -- \ --n_moments 5 --n_qubits 4 \ @@ -39,11 +39,10 @@ benchmarks/scripts/reports/CliffordBenchmarks.benchmark_clifford_circuit_4_5_1 To benchmark the parameter shift differentiation method on a random depth-10 4-qubit circuit with 10 parameters call, where the circuit will be differentiated over 50 trials, each time over a batch of 10 circuits. ``` -bazel run -c opt --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=1" --cxxopt="-msse2" \ +bazel run -c opt --cxxopt="-msse2" \ --cxxopt="-msse3" --cxxopt="-msse4" \ benchmarks/scripts:benchmark_op_gradients -- \ --n_moments 10 --n_qubits 4 --n_symbols 10 \ --n_runs 50 --batch_size 10 \ --benchmarks=benchmark_parameter_shift ``` - diff --git a/scripts/benchmark_all.sh b/scripts/benchmark_all.sh index cd50209c2..642496aef 100755 --- a/scripts/benchmark_all.sh +++ b/scripts/benchmark_all.sh @@ -1,12 +1,12 @@ #!/bin/bash # Copyright 2020 The TensorFlow Quantum Authors. All Rights Reserved. -# +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -14,7 +14,7 @@ # limitations under the License. # ============================================================================== echo "Testing benchmarks."; -test_outputs=$(bazel test -c opt --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=1" --cxxopt="-msse2" --cxxopt="-msse3" --cxxopt="-msse4" --test_output=errors $(bazel query //benchmarks/...)) +test_outputs=$(bazel test -c opt --cxxopt="-msse2" --cxxopt="-msse3" --cxxopt="-msse4" --test_output=errors $(bazel query //benchmarks/...)) exit_code=$? if [ "$exit_code" == "0" ]; then @@ -26,5 +26,5 @@ else fi echo "Running preconfigured benchmarks."; -bazel_run=${bazel run -c opt --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=1" --cxxopt="-msse2" --cxxopt="-msse3" --cxxopt="-msse4"} -bazel_run benchmarks/scripts:benchmark_clifford_circuit -- --op_density 1 --n_moments 10 --n_qubits 4 \ No newline at end of file +bazel_run=${bazel run -c opt --cxxopt="-msse2" --cxxopt="-msse3" --cxxopt="-msse4"} +bazel_run benchmarks/scripts:benchmark_clifford_circuit -- --op_density 1 --n_moments 10 --n_qubits 4 diff --git a/scripts/build_pip_package_test.sh b/scripts/build_pip_package_test.sh index 644338b6a..c77091945 100755 --- a/scripts/build_pip_package_test.sh +++ b/scripts/build_pip_package_test.sh @@ -1,12 +1,12 @@ #!/bin/bash # Copyright 2020 The TensorFlow Quantum Authors. All Rights Reserved. -# +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,7 +19,7 @@ pip install -r requirements.txt # cd tensorflow_quantum echo "Y\n" | ./configure.sh -bazel build -c opt --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=1" --cxxopt="-msse2" --cxxopt="-msse3" --cxxopt="-msse4" release:build_pip_package +bazel build -c opt --cxxopt="-msse2" --cxxopt="-msse3" --cxxopt="-msse4" release:build_pip_package rm /tmp/tensorflow_quantum/* || echo ok bazel-bin/release/build_pip_package /tmp/tensorflow_quantum/ pip install -U /tmp/tensorflow_quantum/*.whl diff --git a/scripts/msan_test.sh b/scripts/msan_test.sh index d47e8ccfe..988c623f7 100755 --- a/scripts/msan_test.sh +++ b/scripts/msan_test.sh @@ -1,12 +1,12 @@ #!/bin/bash # Copyright 2020 The TensorFlow Quantum Authors. All Rights Reserved. -# +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -14,19 +14,19 @@ # limitations under the License. # ============================================================================== echo "Testing All Bazel cc_tests with msan."; -test_outputs=$(bazel test -c opt --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=1" \ +test_outputs=$(bazel test -c opt \ --cxxopt="-msse2" --cxxopt="-msse3" --cxxopt="-msse4" \ --cxxopt="-fsanitize=address" --linkopt="-fsanitize=address" \ --cxxopt="-g" --cxxopt="-O0" \ --notest_keep_going --test_output=errors \ //tensorflow_quantum/core/src:all && \ - bazel test -c opt --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=1" \ + bazel test -c opt \ --cxxopt="-mavx2" --cxxopt="-mavx" --cxxopt="-mfma" \ --cxxopt="-fsanitize=address" --linkopt="-fsanitize=address" \ --cxxopt="-g" --cxxopt="-O0" \ --notest_keep_going --test_output=errors \ //tensorflow_quantum/core/src:all && \ - bazel test -c opt --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=1" \ + bazel test -c opt \ --cxxopt="-fsanitize=address" --linkopt="-fsanitize=address" \ --cxxopt="-g" --cxxopt="-O0" \ --notest_keep_going --test_output=errors \ @@ -39,4 +39,4 @@ else echo "Testing failed, please correct errors before proceeding." echo "{$test_outputs}" exit 64; -fi \ No newline at end of file +fi diff --git a/scripts/test_all.sh b/scripts/test_all.sh index 5d5405fac..1601a1607 100755 --- a/scripts/test_all.sh +++ b/scripts/test_all.sh @@ -1,12 +1,12 @@ #!/bin/bash # Copyright 2020 The TensorFlow Quantum Authors. All Rights Reserved. -# +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -14,7 +14,7 @@ # limitations under the License. # ============================================================================== echo "Testing All Bazel py_test and cc_tests."; -test_outputs=$(bazel test -c opt --experimental_repo_remote_exec --test_output=errors --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=1" --cxxopt="-std=c++17" --cxxopt="-msse2" --cxxopt="-msse3" --cxxopt="-msse4" //tensorflow_quantum/...) +test_outputs=$(bazel test -c opt --experimental_repo_remote_exec --test_output=errors --cxxopt="-std=c++17" --cxxopt="-msse2" --cxxopt="-msse3" --cxxopt="-msse4" //tensorflow_quantum/...) exit_code=$? if [ "$exit_code" == "0" ]; then echo "Testing Complete!"; diff --git a/scripts/test_benchmarks.sh b/scripts/test_benchmarks.sh index 07e3adec1..a37d31ec0 100755 --- a/scripts/test_benchmarks.sh +++ b/scripts/test_benchmarks.sh @@ -1,12 +1,12 @@ #!/bin/bash # Copyright 2020 The TensorFlow Quantum Authors. All Rights Reserved. -# +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -14,10 +14,10 @@ # limitations under the License. # ============================================================================== echo "Testing all Benchmarks."; -bazel test -c opt --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=1" --cxxopt="-msse2" --cxxopt="-msse3" --cxxopt="-msse4" --test_output=errors $(bazel query //benchmarks/scripts:all) -# test_outputs=$(bazel test -c opt --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=1" --cxxopt="-msse2" --cxxopt="-msse3" --cxxopt="-msse4" --test_output=errors $(bazel query //benchmarks/scripts:all)) +bazel test -c opt --cxxopt="-msse2" --cxxopt="-msse3" --cxxopt="-msse4" --test_output=errors $(bazel query //benchmarks/scripts:all) +# test_outputs=$(bazel test -c opt --cxxopt="-msse2" --cxxopt="-msse3" --cxxopt="-msse4" --test_output=errors $(bazel query //benchmarks/scripts:all)) bench_outputs=$() -# bench_outputs=$(bazel run -c opt --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=1" --cxxopt="-msse2" --cxxopt="-msse3" --cxxopt="-msse4" --test_output=errors //benchmarks/scripts:benchmark_clifford_circuit) +# bench_outputs=$(bazel run -c opt --cxxopt="-msse2" --cxxopt="-msse3" --cxxopt="-msse4" --test_output=errors //benchmarks/scripts:benchmark_clifford_circuit) exit_code=$? if [ "$exit_code" == "0" ]; then echo "Testing Complete!"; @@ -26,4 +26,4 @@ else echo "Testing failed, please correct errors before proceeding." echo "{$test_outputs}" exit 64; -fi \ No newline at end of file +fi