Don't link against explicit instances of libm, librt, etc..
The current way adds unnecessary RPATH entries into the binaries that
aren't helpful. This patch just adds linkopts to the apprpriate
targets to let the linker decide what to do.
This should allow us to run binaries on Debian 8 that were compiled on
Debian 9 with a sandboxed compiler.
Change-Id: Icdec2ffbd12f83b72a4ab678b8fcbbb2adc12bc5
diff --git a/aos/common/util/BUILD b/aos/common/util/BUILD
index 4e0455b..cd58bbf 100644
--- a/aos/common/util/BUILD
+++ b/aos/common/util/BUILD
@@ -126,7 +126,9 @@
'//third_party/eigen',
'//aos/common:time',
'//aos/common/logging',
- '//debian:libm',
+ ],
+ linkopts = [
+ '-lm',
],
)
diff --git a/aos/linux_code/BUILD b/aos/linux_code/BUILD
index 0b76e2c..259538c 100644
--- a/aos/linux_code/BUILD
+++ b/aos/linux_code/BUILD
@@ -31,7 +31,9 @@
deps = [
'//aos:once',
'//aos/common:die',
- '//debian:libpthread',
+ ],
+ linkopts = [
+ "-pthread",
],
)
diff --git a/aos/linux_code/ipc_lib/BUILD b/aos/linux_code/ipc_lib/BUILD
index b0b58ff..8b8686d 100644
--- a/aos/linux_code/ipc_lib/BUILD
+++ b/aos/linux_code/ipc_lib/BUILD
@@ -46,7 +46,9 @@
':core_lib',
':shared_mem_types',
'//aos/common/logging',
- '//debian:librt',
+ ],
+ linkopts = [
+ '-lrt',
],
)
@@ -76,9 +78,11 @@
':core_lib',
':shared_mem',
'//aos/common/logging',
- '//debian:librt',
'//aos/common/util:options',
],
+ linkopts = [
+ '-lrt',
+ ],
)
cc_test(
diff --git a/debian/BUILD b/debian/BUILD
index 26d0f8c..a20b894 100644
--- a/debian/BUILD
+++ b/debian/BUILD
@@ -1,12 +1,3 @@
package(default_visibility = ['//visibility:public'])
-load('//tools/build_rules:select.bzl', 'cpu_select')
-
-[ cc_library(
- name = libname,
- deps = cpu_select({
- "roborio": ['@arm_frc_linux_gnueabi_repo//:' + libname],
- "amd64": ['@usr_repo//:' + libname],
- "armhf": ['@linaro_linux_gcc_4_9_repo//:' + libname],
- }),
-) for libname in ['libpthread', 'libm', 'libdl', 'librt']]
+# TODO(phil): Add deb-to-tarball targets here.
diff --git a/frc971/control_loops/BUILD b/frc971/control_loops/BUILD
index 5998afc..4951d86 100644
--- a/frc971/control_loops/BUILD
+++ b/frc971/control_loops/BUILD
@@ -72,7 +72,9 @@
":gaussian_noise",
":queues",
"//aos/testing:random_seed",
- "//debian:libm",
+ ],
+ linkopts = [
+ "-lm",
],
)
@@ -84,8 +86,8 @@
hdrs = [
"gaussian_noise.h",
],
- deps = [
- "//debian:libm",
+ linkopts = [
+ "-lm",
],
)
@@ -114,9 +116,11 @@
],
deps = [
"//aos/common/controls:polytope",
- "//debian:libm",
"//third_party/eigen",
],
+ linkopts = [
+ "-lm",
+ ],
)
# TODO(austin): Select isn't working right. We should be able to remove
diff --git a/third_party/gflags/BUILD b/third_party/gflags/BUILD
index cffd8fe..2b84041 100644
--- a/third_party/gflags/BUILD
+++ b/third_party/gflags/BUILD
@@ -42,9 +42,11 @@
'include/gflags/gflags_completions.h',
],
deps = [
- '//debian:libpthread',
'//third_party/empty_config_h',
],
+ linkopts = [
+ '-pthread',
+ ],
copts = common_copts,
includes = [ 'include' ],
)
diff --git a/third_party/gperftools/BUILD b/third_party/gperftools/BUILD
index 3310c78..c0fa7c0 100644
--- a/third_party/gperftools/BUILD
+++ b/third_party/gperftools/BUILD
@@ -134,11 +134,11 @@
'src/debugallocation.cc',
]),
deps = [
- '//debian:librt',
'//third_party/empty_config_h',
],
copts = common_copts,
linkopts = [
+ '-lrt',
'-pthread',
],
alwayslink = True,
diff --git a/y2014/control_loops/claw/BUILD b/y2014/control_loops/claw/BUILD
index a3a0d5c..1c0d157 100644
--- a/y2014/control_loops/claw/BUILD
+++ b/y2014/control_loops/claw/BUILD
@@ -55,12 +55,14 @@
'//aos/common/logging:queue_logging',
'//aos/common/logging:matrix_logging',
'//aos/common:math',
- '//debian:libm',
'//frc971/control_loops:state_feedback_loop',
'//frc971/control_loops:coerce_goal',
'//frc971/control_loops:hall_effect_tracker',
'//y2014:constants',
],
+ linkopts = [
+ '-lm',
+ ],
)
cc_test(
diff --git a/y2014/control_loops/shooter/BUILD b/y2014/control_loops/shooter/BUILD
index 9f92f17..6ab2a8b 100644
--- a/y2014/control_loops/shooter/BUILD
+++ b/y2014/control_loops/shooter/BUILD
@@ -58,7 +58,9 @@
'//y2014:constants',
'//frc971/control_loops:state_feedback_loop',
'//aos/common/logging:queue_logging',
- '//debian:libm',
+ ],
+ linkopts = [
+ '-lm',
],
)