On Wednesday, April 25 2018, Sébastien Jodogne wrote: > Dear Debian mentors,
Hey, Sébastien, Disclaimer: I'm not a cmake expert. > I write this message as the maintainer of the Debian packages of the > Orthanc project [1]. > > The Debian packages for Orthanc and its associated plugins pay > attention to the fact of *not* setting "-DCMAKE_BUILD_TYPE=Release", > as requested by the Debian policy [2]. TBH I myself wasn't aware of such policy, and there's nothing official written anywhere, as far as I know. I've recently uploaded a package (peek) which was built using cmake and had to use -DCMAKE_BUILD_TYPE=Release because otherwise it'd just build in "debug mode", as you noticed. > However, the source code of the upstream Orthanc project makes many > calls to the "assert()" function of the standard library [3], in order > to help with the early tracking of bugs. Because those assertions are > extremely time-consuming, they should only be enabled in debug builds. So, the only occurrence of NDEBUG that grep could find was: $ grep NDEBUG -r Core/Cache/LeastRecentlyUsedIndex.h:#ifndef NDEBUG And you're right, it does make a sequence of calls to 'assert' in a loop. I find it curious how cmake works, by assuming that you want to enable debug code whenever you don't use "Release" as the CMAKE_BUILD_TYPE. From a quick search, I noticed that a few projects choose to create another flag for controlling NDEBUG separately, which I think is a reasonable thing to do. LLVM seems to be one example. > The assertions can be disabled by defining the macro "NDEBUG" while > compiling the software. Invoking CMake with > "-DCMAKE_BUILD_TYPE=Release" would make "NDEBUG" defined, at least for > gcc and clang [4]. However, because packages of the Orthanc family are > built using "-DCMAKE_BUILD_TYPE=None", "NDEBUG" is left undefined, and > the Orthanc log warns about bad performance: > > > $ sudo apt-get install orthanc > $ head /var/log/orthanc/Orthanc.log > W0424 13:01:40.158634 main.cpp:1298] Orthanc version: 1.3.2 > W0424 13:01:40.158696 main.cpp:1146] Performance warning: Non-release > build, runtime debug assertions are turned on > > > I have not been able to find a definite answer about how "NDEBUG" > should be properly handled. I am considering to add the following > arguments wile invoking CMake in debian/rules in order to have > "NDEBUG" manually defined: > > cmake -DCMAKE_C_FLAGS=-DNDEBUG -DCMAKE_CXX_FLAGS=-DNDEBUG [...] > > Please someone could validate this approach wrt. Debian policy? TIA! As I said, I could not find anything official about using "Release" as the CMAKE_BUILD_TYPE, but I understand if you don't want to enable it. That being said, I think your approach is sensible. Just disable NDEBUG through CFLAGS/CXXFLAGS, and that should do it. This is cleaner than patching the code to remove the assertions, and you can put a comment on d/rules explaining why you're disabling NDEBUG "by hand". My two cents. Cheers, -- Sergio GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36 Please send encrypted e-mail if possible http://sergiodj.net/
signature.asc
Description: PGP signature