diff mbox series

[ovs-dev,ovs] Documentation: Adding note about using the jemalloc library.

Message ID 20240126152308.2146717-1-roberto.acosta@luizalabs.com
State Superseded
Headers show
Series [ovs-dev,ovs] Documentation: Adding note about using the jemalloc library. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Roberto Bartzen Acosta Jan. 26, 2024, 3:23 p.m. UTC
Current version of debian/rules simply uses the default GCC optimization settings during the linkage process.

The main problem with this approach is that GCC on OS like Ubuntu Jammy, for example, can enable the -flto=auto flag option during the Open vSwitch building and linking process. In this case, the linked dynamic libraries would need to be compatible with the same lto optimization options, at the risk of not working, according to documentation [1]. However, it could be possible to link to jemalloc using the LTO option but the GIMPLE-bytecode may not work correctly. In this case, it would be necessary to disable the -fbuiltin flag [2] if it is set as default.

Updating the reference documentation with the inclusion of possible building problems with libjemalloc and solution suggestions.

[1] https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-flto
[2] https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html

Signed-off-by: Roberto Bartzen Acosta <roberto.acosta@luizalabs.com>
---
 Documentation/intro/install/general.rst | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
diff mbox series

Patch

diff --git a/Documentation/intro/install/general.rst b/Documentation/intro/install/general.rst
index 19e360d47..ef4e6181d 100644
--- a/Documentation/intro/install/general.rst
+++ b/Documentation/intro/install/general.rst
@@ -344,6 +344,23 @@  you wish to link with jemalloc add it to LIBS::
 
     $ ./configure LIBS=-ljemalloc
 
+.. note::
+  Linking Open vSwitch with the jemalloc shared library may not work as
+  expected in certain operating system development environments if the GCC
+  compiler tries to optimize the linking process using the ``-flto`` flag.
+  You can overrides the automatic compiler decision removing the link-time
+  optimization by passing ``-fno-lto`` or disabling ``-fno-builtin`` flag since
+  the jemalloc override standard built-in memory allocation functions such as
+  malloc, calloc, etc. Both options can solve possible jemalloc linker issues
+  with pros and cons for each case, feel free to choose the path that appears
+  best to you. Disabling LTO flag example::
+
+      $ ./configure LIBS=-ljemalloc CFLAGS=-fno-lto
+
+  Disabling built-in flag example::
+
+      ./configure LIBS=-ljemalloc CFLAGS=-fno-builtin
+
 .. _general-building:
 
 Building