Bug 425162

Summary: Konsole fails to build
Product: [Applications] konsole Reporter: Martin Sandsmark <martin.sandsmark>
Component: generalAssignee: Konsole Developer <konsole-devel>
Status: RESOLVED FIXED    
Severity: grave CC: tcanabrava
Priority: NOR    
Version: master   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Martin Sandsmark 2020-08-09 14:33:48 UTC
Trying to compile Konsole from the master branch fails with the following error:

/usr/bin/ld: src/session/libkonsolesession.a(SessionController.cpp.o): undefined reference to symbol '_ZN7Konsole15TerminalDisplay13filterActionsERK6QPoint'
/usr/bin/ld: src/libkonsoleprivate.so.20.11.70: error adding symbols: DSO missing from command line

These are my default (system-wide) LDFLAGS:
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
Comment 1 Martin Sandsmark 2020-08-09 14:35:42 UTC
Not entirely sure why everything is split up into separate .so files now? It kills performance (a bit more).
Comment 2 tcanabrava 2020-08-09 15:15:43 UTC
Martin, konsole is not split into multiple .so files, there will not be a performance hit. it's split into multiple static libraries, so it's easier to understand the architecture, and each static library links directly to the libkonsoleprivate.so

I just reverted the commit that broke the build, and that also was a bit of facepalm moment for me:
currently the konsole architecture is broken, as there's a hard dependency on SessionController -> TerminalDisplay, but there's also a hard dependency on TerminalDisplay->SessionController. And this was the cause of the linkage error.

For me, without those flags and gcc 10.1, it compiled fine, so that's the reason I didn't realized sooner.
Comment 3 Martin Sandsmark 2020-08-09 15:19:29 UTC
I meant .a files, it impacts build times a bit. might impact LTO as well, unless we switch to thin archives (which has another bunch of issues).


Alternatively we could do something like this (cmake magic I recently learned), I think that works more like expected (i. e. isn't impacted by LDFLAGS and stuff):

  diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
  index 58b3290f..16fd27af 100644
  --- a/src/CMakeLists.txt
  +++ b/src/CMakeLists.txt
  @@ -205,7 +205,7 @@ ki18n_wrap_ui(konsoleprivate_SRCS
   # add the resource files for the ui files
   qt5_add_resources( konsoleprivate_SRCS ../desktop/konsole.qrc)
   
  -add_library(konsoleprivate ${konsoleprivate_SRCS})
  +add_library(konsoleprivate ${konsoleprivate_SRCS}  $<TARGET_OBJECTS:konsolesession>)
   generate_export_header(konsoleprivate BASE_NAME konsoleprivate)
   
   target_link_libraries(konsoleprivate
  diff --git a/src/session/CMakeLists.txt b/src/session/CMakeLists.txt
  index 1e8f86a2..d4271ab8 100644
  --- a/src/session/CMakeLists.txt
  +++ b/src/session/CMakeLists.txt
  @@ -24,7 +24,7 @@ set(konsole_session_SRCS
   )
   
   add_library(konsolesession
  -    STATIC
  +    OBJECT
       ${konsole_session_SRCS}
   )
   

It makes it harder to depend on other modules (so with this no other modules can depend on konsolesession), but that's really a good thing imho.
Comment 4 Martin Sandsmark 2020-08-09 15:23:10 UTC
But thanks for the quick response!