Skip to content

Commit

Permalink
fix(build):add openresty/lualib into rpath
Browse files Browse the repository at this point in the history
  • Loading branch information
fffonion committed Sep 25, 2023
1 parent 78168f0 commit 07e1766
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 34 deletions.
17 changes: 11 additions & 6 deletions build/openresty/BUILD.openresty.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,15 @@ genrule(
""".format(luajit_version = LUAJIT_VERSION),
)

rpath_flags = "-Wl,-rpath,%s/kong/lib -Wl,-rpath,%s/openresty/lualib" % (
KONG_VAR["INSTALL_DESTDIR"],
KONG_VAR["INSTALL_DESTDIR"],
)

make(
name = "luajit",
args = [
"LDFLAGS=\"-Wl,-rpath,%s/kong/lib\"" % KONG_VAR["INSTALL_DESTDIR"], # make ffi.load happy, even when it's invoked without nginx
"LDFLAGS=\"%s\"" % rpath_flags, # make ffi.load happy, even when it's invoked without nginx
"XCFLAGS=\"$(cat $$EXT_BUILD_ROOT$$/$(execpath :luajit_xcflags))\"",
"LUA_ROOT=%s/openresty/luajit" % KONG_VAR["INSTALL_DESTDIR"].rstrip("/"),
"MACOSX_DEPLOYMENT_TARGET=" + KONG_VAR["MACOSX_DEPLOYMENT_TARGET"],
Expand Down Expand Up @@ -140,12 +145,12 @@ CONFIGURE_OPTIONS = [
"--with-ld-opt=\"-L$$EXT_BUILD_DEPS$$/pcre/lib\"",
"--with-ld-opt=\"-L$$EXT_BUILD_DEPS$$/openssl/lib\"",
"--with-ld-opt=\"-L$$EXT_BUILD_DEPS$$/luajit/lib\"",
# here let's try not having --disable-new-dtags; --disable-new-dtags creates runpath instead of rpath
# note runpath can't handle indirect dependency (nginx -> luajit -> dlopen("other")), so each indirect
# Here let's try not having --disable-new-dtags; --disable-new-dtags creates rpath instead of runpath
# note rpath can't handle indirect dependency (nginx -> luajit -> dlopen("other")), so each indirect
# dependency should have its rpath set (luajit, libxslt etc); on the other side, rpath is not
# overridable by LD_LIBRARY_PATH and it may cause trouble debugging, so we _should_ prefer runpath.
# if it doesn't work, then add --disable-new-dtags back
"--with-ld-opt=\"-Wl,-rpath,%s/kong/lib\"" % KONG_VAR["INSTALL_DESTDIR"],
# overridable by LD_LIBRARY_PATH and it may cause trouble debugging, so we _should_ prefer runpath
# whenever available.
"--with-ld-opt=\"%s\"" % rpath_flags,
"-j%s" % KONG_VAR["NPROC"],

# options from our customed patch
Expand Down
2 changes: 1 addition & 1 deletion scripts/explain_manifest/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def transform(f: FileInfo):
# otherwise remain unmodified

if f.path.endswith("/modules/ngx_wasm_module.so"):
expected_rpath = "/usr/local/openresty/luajit/lib:/usr/local/kong/lib"
expected_rpath = "/usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib"
if f.rpath and expected_rpath in f.rpath:
f.rpath = expected_rpath
elif f.runpath and expected_rpath in f.runpath:
Expand Down
2 changes: 1 addition & 1 deletion scripts/explain_manifest/fixtures/alpine-amd64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
- libcrypto.so.1.1
- libz.so.1
- libc.so
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib
Modules :
- lua-kong-nginx-module
- lua-kong-nginx-module/stream
Expand Down
2 changes: 1 addition & 1 deletion scripts/explain_manifest/fixtures/alpine-arm64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
- libcrypto.so.1.1
- libz.so.1
- libc.so
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib
Modules :
- lua-kong-nginx-module
- lua-kong-nginx-module/stream
Expand Down
4 changes: 2 additions & 2 deletions scripts/explain_manifest/fixtures/amazonlinux-2-amd64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
- libgcc_s.so.1
- libc.so.6
- ld-linux-x86-64.so.2
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib

- Path : /usr/local/openresty/nginx/sbin/nginx
Needed :
Expand All @@ -195,7 +195,7 @@
- libcrypto.so.3
- libz.so.1
- libc.so.6
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib
Modules :
- lua-kong-nginx-module
- lua-kong-nginx-module/stream
Expand Down
4 changes: 2 additions & 2 deletions scripts/explain_manifest/fixtures/amazonlinux-2023-amd64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
- libgcc_s.so.1
- libc.so.6
- ld-linux-x86-64.so.2
Runpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib
Runpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib

- Path : /usr/local/openresty/nginx/sbin/nginx
Needed :
Expand All @@ -181,7 +181,7 @@
- libcrypto.so.3
- libz.so.1
- libc.so.6
Runpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib
Runpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib
Modules :
- lua-kong-nginx-module
- lua-kong-nginx-module/stream
Expand Down
4 changes: 2 additions & 2 deletions scripts/explain_manifest/fixtures/amazonlinux-2023-arm64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
- libgcc_s.so.1
- libc.so.6
- ld-linux-aarch64.so.1
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib

- Path : /usr/local/openresty/nginx/sbin/nginx
Needed :
Expand All @@ -163,7 +163,7 @@
- libcrypto.so.3
- libz.so.1
- libc.so.6
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib
Modules :
- lua-kong-nginx-module
- lua-kong-nginx-module/stream
Expand Down
4 changes: 2 additions & 2 deletions scripts/explain_manifest/fixtures/debian-10-amd64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
- libgcc_s.so.1
- libc.so.6
- ld-linux-x86-64.so.2
Runpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib
Runpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib

- Path : /usr/local/openresty/nginx/sbin/nginx
Needed :
Expand All @@ -195,7 +195,7 @@
- libcrypto.so.3
- libz.so.1
- libc.so.6
Runpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib
Runpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib
Modules :
- lua-kong-nginx-module
- lua-kong-nginx-module/stream
Expand Down
4 changes: 2 additions & 2 deletions scripts/explain_manifest/fixtures/debian-11-amd64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
- libgcc_s.so.1
- libc.so.6
- ld-linux-x86-64.so.2
Runpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib
Runpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib

- Path : /usr/local/openresty/nginx/sbin/nginx
Needed :
Expand All @@ -183,7 +183,7 @@
- libcrypto.so.3
- libz.so.1
- libc.so.6
Runpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib
Runpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib
Modules :
- lua-kong-nginx-module
- lua-kong-nginx-module/stream
Expand Down
4 changes: 2 additions & 2 deletions scripts/explain_manifest/fixtures/el7-amd64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
- libgcc_s.so.1
- libc.so.6
- ld-linux-x86-64.so.2
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib

- Path : /usr/local/openresty/nginx/sbin/nginx
Needed :
Expand All @@ -195,7 +195,7 @@
- libcrypto.so.3
- libz.so.1
- libc.so.6
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib
Modules :
- lua-kong-nginx-module
- lua-kong-nginx-module/stream
Expand Down
4 changes: 2 additions & 2 deletions scripts/explain_manifest/fixtures/el8-amd64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
- libgcc_s.so.1
- libc.so.6
- ld-linux-x86-64.so.2
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib

- Path : /usr/local/openresty/nginx/sbin/nginx
Needed :
Expand All @@ -194,7 +194,7 @@
- libcrypto.so.3
- libz.so.1
- libc.so.6
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib
Modules :
- lua-kong-nginx-module
- lua-kong-nginx-module/stream
Expand Down
4 changes: 2 additions & 2 deletions scripts/explain_manifest/fixtures/el9-amd64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
- libgcc_s.so.1
- libc.so.6
- ld-linux-x86-64.so.2
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib

- Path : /usr/local/openresty/nginx/sbin/nginx
Needed :
Expand All @@ -181,7 +181,7 @@
- libcrypto.so.3
- libz.so.1
- libc.so.6
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib
Modules :
- lua-kong-nginx-module
- lua-kong-nginx-module/stream
Expand Down
4 changes: 2 additions & 2 deletions scripts/explain_manifest/fixtures/el9-arm64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
- libgcc_s.so.1
- libc.so.6
- ld-linux-aarch64.so.1
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib

- Path : /usr/local/openresty/nginx/sbin/nginx
Needed :
Expand All @@ -163,7 +163,7 @@
- libcrypto.so.3
- libz.so.1
- libc.so.6
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib
Rpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib
Modules :
- lua-kong-nginx-module
- lua-kong-nginx-module/stream
Expand Down
4 changes: 2 additions & 2 deletions scripts/explain_manifest/fixtures/ubuntu-20.04-amd64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
- libgcc_s.so.1
- libc.so.6
- ld-linux-x86-64.so.2
Runpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib
Runpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib

- Path : /usr/local/openresty/nginx/sbin/nginx
Needed :
Expand All @@ -187,7 +187,7 @@
- libcrypto.so.3
- libz.so.1
- libc.so.6
Runpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib
Runpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib
Modules :
- lua-kong-nginx-module
- lua-kong-nginx-module/stream
Expand Down
4 changes: 2 additions & 2 deletions scripts/explain_manifest/fixtures/ubuntu-22.04-amd64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
- libgcc_s.so.1
- libc.so.6
- ld-linux-x86-64.so.2
Runpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib
Runpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib

- Path : /usr/local/openresty/nginx/sbin/nginx
Needed :
Expand All @@ -174,7 +174,7 @@
- libcrypto.so.3
- libz.so.1
- libc.so.6
Runpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib
Runpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib
Modules :
- lua-kong-nginx-module
- lua-kong-nginx-module/stream
Expand Down
4 changes: 2 additions & 2 deletions scripts/explain_manifest/fixtures/ubuntu-22.04-arm64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
- libgcc_s.so.1
- libc.so.6
- ld-linux-aarch64.so.1
Runpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib
Runpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib

- Path : /usr/local/openresty/nginx/sbin/nginx
Needed :
Expand All @@ -172,7 +172,7 @@
- libz.so.1
- libc.so.6
- ld-linux-aarch64.so.1
Runpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib
Runpath : /usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib
Modules :
- lua-kong-nginx-module
- lua-kong-nginx-module/stream
Expand Down
2 changes: 1 addition & 1 deletion scripts/explain_manifest/suites.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def common_suites(expect, libxcrypt_no_obsolete_api: bool = False):

# binary correctness
expect("/usr/local/openresty/nginx/sbin/nginx", "nginx rpath should contain kong lib") \
.rpath.equals("/usr/local/openresty/luajit/lib:/usr/local/kong/lib")
.rpath.equals("/usr/local/openresty/luajit/lib:/usr/local/kong/lib:/usr/local/openresty/lualib")

expect("/usr/local/openresty/nginx/sbin/nginx", "nginx binary should contain dwarf info for dynatrace") \
.has_dwarf_info.equals(True) \
Expand Down

1 comment on commit 07e1766

@khcp-gha-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bazel Build

Docker image available kong/kong:07e1766adc6a8e0df189d007dc3488a3ec923005
Artifacts available https://github.com/Kong/kong/actions/runs/6296741448

Please sign in to comment.