0001-src-rebar_port_compiler-add-fPIC-to-LDFLAGS-by-defau.patch 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. From 7f54d48ee5db037778ead310e0b8278f3fe70b41 Mon Sep 17 00:00:00 2001
  2. From: Giulio Benetti <giulio.benetti@benettiengineering.com>
  3. Date: Sun, 19 Dec 2021 07:52:55 +0100
  4. Subject: [PATCH] src/rebar_port_compiler: add -fPIC to LDFLAGS by default
  5. Since both DRV_CFLAGS and EXE_CFLAGS list -fPIC we need also the LDFLAGS
  6. to follow them. Unfortunately adding -fPIC only to DRV_LDFLAGS and
  7. EXE_LDFLAGS is not sufficient, since when linking as a library(.so) it
  8. doesn't take into account those variables. Since -fPIC is needed by default
  9. by any kind of linking, let's add it to the general -fPIC. Rebar seems to
  10. link libraries without taking into account any variable listed in:
  11. src/rebar_port_compiler.erl
  12. this after testing and tracing for every variable.
  13. Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
  14. ---
  15. src/rebar_port_compiler.erl | 2 ++
  16. 1 file changed, 2 insertions(+)
  17. diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl
  18. index 9679c80..bd08b21 100644
  19. --- a/src/rebar_port_compiler.erl
  20. +++ b/src/rebar_port_compiler.erl
  21. @@ -645,6 +645,8 @@ default_env() ->
  22. {"OBJCOPY", get_tool(Arch, "objcopy", "objcopy")},
  23. {"OBJDUMP", get_tool(Arch, "objdump", "objdump")},
  24. + {"LDFLAGS", "-fPIC $LDFLAGS"},
  25. +
  26. {"DRV_CXX_TEMPLATE",
  27. "$CXX -c $CXXFLAGS $DRV_CFLAGS $PORT_IN_FILES -o $PORT_OUT_FILE"},
  28. {"DRV_CC_TEMPLATE",
  29. --
  30. 2.25.1