Bug 471836

Summary: Build failure with -flto -Werror=odr: kded/engine/backends/cryfs/cryfsbackend.cpp:33:12: error: type ‘PlasmaVault::ExitCode’ violates the C++ One Definition Rule [-Werror=odr]
Product: [Plasma] Plasma Vault Reporter: kocelfc
Component: generalAssignee: Ivan Čukić <ivan.cukic>
Status: RESOLVED NOT A BUG    
Severity: normal CC: nate
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: complete build log

Description kocelfc 2023-07-01 15:41:49 UTC
Created attachment 160026 [details]
complete build log

SUMMARY

plasma-vault 5.27.6 fails to compile with -flto -Werror=odr added to CFLAGS and CXXFLAGS


/home/kostadin/plasma-vault/kded/engine/backends/cryfs/cryfsbackend.cpp:33:12: error: type ‘PlasmaVault::ExitCode’ violates the C++ One Definition Rule [-Werror=odr]
   33 | enum class ExitCode : int {
      |            ^
/home/kostadin/plasma-vault/kded/engine/backends/gocryptfs/gocryptfsbackend.cpp:32:12: note: an enum with different value name is defined in another translation unit
   32 | enum class ExitCode : int {
      |            ^
/home/kostadin/plasma-vault/kded/engine/backends/cryfs/cryfsbackend.cpp:37:5: note: name ‘UnspecifiedError’ differs from name ‘NonEmptyCipherDir’ defined in another translation unit
   37 |     UnspecifiedError = 1,
      |     ^
/home/kostadin/plasma-vault/kded/engine/backends/gocryptfs/gocryptfsbackend.cpp:36:5: note: mismatching definition
   36 |     NonEmptyCipherDir = 6,
      |     ^
lto1: some warnings being treated as errors
lto-wrapper: fatal error: /usr/bin/c++ returned 1 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status


STEPS TO REPRODUCE
1. git clone -b Plasma/5.27 https://invent.kde.org/plasma/plasma-vault.git
2. cd plasma-vault
3. mkdir build && cd build
4. run `CFLAGS="-O2 -flto -Werror=odr" CXXFLAGS="-O2 -flto -Werror=odr" cmake ..
5. make

OBSERVED RESULT

Build fails due to ODR violations 

EXPECTED RESULT

Build completes fine with no errors


SOFTWARE/OS VERSIONS
Gentoo Linux 2.13
KDE Plasma Version: 5.27.6
KDE Frameworks Version: 5.107.0
Qt Version: 5.15.10

ADDITIONAL INFORMATION
gcc version: (Gentoo 13.1.1_p20230527 p3) 13.1.1 20230527
Comment 1 Nate Graham 2023-09-13 18:56:19 UTC
We don't build with -Werror by default, and as such, this isn't considered a bug that's trackable in the bug tracker system. But please do feel free to submit a merge request to improve it!