Skip to content

Instantly share code, notes, and snippets.

@roobie
Created May 31, 2020 15:13
Show Gist options
  • Save roobie/8dc7e505081031602cc3da51b05c5f3d to your computer and use it in GitHub Desktop.
Save roobie/8dc7e505081031602cc3da51b05c5f3d to your computer and use it in GitHub Desktop.
default-ldflags-with-runpath
(def *default-ldflags* "-s")
(def zlib {:path "/abc/zlib"})
(def libuv {:path "/abc/libuv"})
(defn default-ldflags-with-runpath [&keys collections]
(var to-join @[])
(each key (keys collections)
(let [prefix (string "/" key)
libs (in collections key)
extra (join-pkg-paths ":" prefix libs)]
(set to-join (array/concat to-join extra))))
(string *default-ldflags*
" "
"-Wl,--enable-new-dtags"
" "
"-Wl,-rpath=" (string/join to-join ":")))
(print (default-ldflags-with-runpath :lib [zlib] :lib64 [libuv]))
(print (default-ldflags-with-runpath :lib64 [libuv]))
(print (default-ldflags-with-runpath :lib [zlib]))
# Output
# -s -Wl,--enable-new-dtags -Wl,-rpath=/abc/zlib/lib:/abc/libuv/lib64
# -s -Wl,--enable-new-dtags -Wl,-rpath=/abc/libuv/lib64
# -s -Wl,--enable-new-dtags -Wl,-rpath=/abc/zlib/lib
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment