From 06ae3073ba650504c3bd59dbfc86ed1311815732 Mon Sep 17 00:00:00 2001 From: tyler-yankee Date: Tue, 15 Jul 2025 10:48:45 -0400 Subject: [PATCH] [Bazel examples] Use prefer_pic_for_opt_binaries Drake upstream has switched to using prefer_pic_for_opt_binaries, which supplants --force_pic (and avoids the platform-specific logic of when to use it). Downstream users must also apply it to their own builds. --- drake_bazel_download/.bazelrc | 6 +----- drake_bazel_external/.bazelrc | 6 +----- drake_bazel_external/.github/ci_build_test | 4 ---- drake_bazel_external_legacy/.bazelrc | 6 +----- drake_bazel_external_legacy/.github/ci_build_test | 4 ---- 5 files changed, 3 insertions(+), 23 deletions(-) diff --git a/drake_bazel_download/.bazelrc b/drake_bazel_download/.bazelrc index 6bbaf487..846eaab4 100644 --- a/drake_bazel_download/.bazelrc +++ b/drake_bazel_download/.bazelrc @@ -2,6 +2,7 @@ # Default to an optimized build. build --compilation_mode=opt +build --features=prefer_pic_for_opt_binaries # Default build options. build --strip=never @@ -17,11 +18,6 @@ build --host_cxxopt=-std=c++20 # https://github.com/bazelbuild/bazel/issues/1164 build --action_env=CCACHE_DISABLE=1 -# For Ubuntu builds, this flag can cut build times in half. For macOS builds, -# this flag might cause build errors. We suggest turning it on if and only if -# your project doesn't use macOS. -## build --force_pic=yes - # TODO(jwnimmer-tri) We should see if we can reuse more of Drake's # customizations somehow. diff --git a/drake_bazel_external/.bazelrc b/drake_bazel_external/.bazelrc index cf36938c..a8b15df7 100644 --- a/drake_bazel_external/.bazelrc +++ b/drake_bazel_external/.bazelrc @@ -2,6 +2,7 @@ # Default to an optimized build. build --compilation_mode=opt +build --features=prefer_pic_for_opt_binaries # Default build options. build --strip=never @@ -30,11 +31,6 @@ build --@drake//tools/flags:public_repo_default=pkgconfig # version as necessary. # build --@drake//tools/cc_toolchain:compiler_major=13 -# For Ubuntu builds, this flag can cut build times in half. For macOS builds, -# this flag might cause build errors. We suggest turning it on if and only if -# your project doesn't use macOS. -## build --force_pic=yes - # Drake supports the use of proprietary solvers for mathematical programs. # See https://drake.mit.edu/bazel.html#proprietary-solvers for more info # and details on how to set them up. diff --git a/drake_bazel_external/.github/ci_build_test b/drake_bazel_external/.github/ci_build_test index 074f0257..eaffd9f6 100755 --- a/drake_bazel_external/.github/ci_build_test +++ b/drake_bazel_external/.github/ci_build_test @@ -12,10 +12,6 @@ build --override_module=drake=drake # Pass along the compiler version to Drake # (as suggested in drake_bazel_external/.bazelrc). build --@drake//tools/cc_toolchain:compiler_major=$(gcc -dumpversion) - -# Use force_pic to speed up the build, as this only runs on Ubuntu -# (as suggested in drake_bazel_external/.bazelrc). -build --force_pic=yes EOF bazel version diff --git a/drake_bazel_external_legacy/.bazelrc b/drake_bazel_external_legacy/.bazelrc index 5f7bf003..4ae3c2fd 100644 --- a/drake_bazel_external_legacy/.bazelrc +++ b/drake_bazel_external_legacy/.bazelrc @@ -6,6 +6,7 @@ common --enable_bzlmod=false # Default to an optimized build. build --compilation_mode=opt +build --features=prefer_pic_for_opt_binaries # Default build options. build --strip=never @@ -29,11 +30,6 @@ build --action_env=CCACHE_DISABLE=1 # version as necessary. # build --@drake//tools/cc_toolchain:compiler_major=13 -# For Ubuntu builds, this flag can cut build times in half. For macOS builds, -# this flag might cause build errors. We suggest turning it on if and only if -# your project doesn't use macOS. -## build --force_pic=yes - # TODO(jwnimmer-tri) We should see if we can reuse more of Drake's # customizations somehow. diff --git a/drake_bazel_external_legacy/.github/ci_build_test b/drake_bazel_external_legacy/.github/ci_build_test index 3ade76f0..64f228aa 100755 --- a/drake_bazel_external_legacy/.github/ci_build_test +++ b/drake_bazel_external_legacy/.github/ci_build_test @@ -7,10 +7,6 @@ cat < "user.bazelrc" # Pass along the compiler version to Drake # (as suggested in drake_bazel_external/.bazelrc). build --@drake//tools/cc_toolchain:compiler_major=$(gcc -dumpversion) - -# Use force_pic to speed up the build, as this only runs on Ubuntu -# (as suggested in drake_bazel_external/.bazelrc). -build --force_pic=yes EOF # Use what we downloaded to drake_bazel_external_legacy/drake,