Fix slycot python library for newer bazel versions
When upgrading to the latest bazel, I kept seeing errors like this:
File "/dev/shm/bazel-sandbox.62240ff599163761312fdbd652f7452abc23edc253dee6214f406f29dde5568b/linux-sandbox/2481/execroot/org_frc971/bazel-out/host/bin/y2019/control_loops/python/intake.runfiles/slycot_repo/slycot/_wrapper.py", line 1, in <module>
from slycot._fortranwrapper import *
ImportError: dynamic module does not define init function (init_fortranwrapper)
And sure enough:
$ objdump -TC bazel-bin/external/slycot_repo/slycot/_fortranwrapper.so
bazel-bin/external/slycot_repo/slycot/_fortranwrapper.so: file format elf64-x86-64
DYNAMIC SYMBOL TABLE:
0000000000000000 w D *UND* 0000000000000000 __gmon_start__
0000000000000000 w DF *UND* 0000000000000000 GLIBC_2.2.5 __cxa_finalize
0000000000000000 w D *UND* 0000000000000000 _ITM_deregisterTMCloneTable
0000000000000000 w D *UND* 0000000000000000 _ITM_registerTMCloneTable
0000000000002009 g D .fini_array 0000000000000000 Base _end
0000000000002008 g D .fini_array 0000000000000000 Base _edata
0000000000002008 g D .fini_array 0000000000000000 Base __bss_start
With version 1.0, bazel changed the default linker flags. See
https://github.com/bazelbuild/bazel/issues/7362 for some more
information.
This patch forces the symbols defined in the `cc_library` to make it
into the .so file.
Change-Id: Id71f57001ae84ee37d5951eb54261c0774320ff4
diff --git a/debian/slycot.BUILD b/debian/slycot.BUILD
index 393de22..a384ebd 100644
--- a/debian/slycot.BUILD
+++ b/debian/slycot.BUILD
@@ -87,6 +87,8 @@
"@python_repo//:python2.7_f2py",
"@python_repo//:python2.7_lib",
],
+ # Make sure this gets included in the .so.
+ alwayslink = True,
)
# Link it all together. Make sure all the deps get static linked into a single