diff mbox series

[bug#53015,2/4] gnu: spdlog: Build with '-fpic'.

Message ID WKX-vcLj5jIxkk1xGaGz3gMBXCW-J0fOc9kOgQ0YJiqfOIp2cqFcK7Z70081d9aqNeWbRFvlLUa6mEmc6IAdHKc3ALz9zwONM44Ehu12CKA=@protonmail.com
State Accepted
Headers show
Series Add mangohud (update dear-imgui) | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

John Kehayias Jan. 4, 2022, 10:24 p.m. UTC
Empty Message

Comments

John Kehayias Jan. 22, 2022, 5:06 a.m. UTC | #1
Hello,

This patch (2/4 build option for spdlog, part of the MangoHud patch series) may be superseded by https://git.savannah.gnu.org/cgit/guix.git/commit/?id=b1542d59606919d0da04914fa6916b85354e2f89  (CCing Nicolas, hope that's okay!) I've built MangoHud with the shared spdlog before, seems to work.

However, given what spdlog has in its documentation, I wonder if it would be better to default to the static version as before? I think the "-fpic" build option would also work for shared linking in general? Or does that not work for nheko, which this change was for I believe?

I'm not really sure though, nor have a strong opinion, just going based on spdlog's info and that some projects (like MangoHud) build spdlog as a static library by default when bundling. I'm guessing it is for performance reasons, though I don't know if that is realized.

John
Maxim Cournoyer Feb. 21, 2022, 4:11 a.m. UTC | #2
Hi John,

John Kehayias <john.kehayias@protonmail.com> writes:

> Hello,
>
> This patch (2/4 build option for spdlog, part of the MangoHud patch
> series) may be superseded by
> https://git.savannah.gnu.org/cgit/guix.git/commit/?id=b1542d59606919d0da04914fa6916b85354e2f89
> (CCing Nicolas, hope that's okay!) I've built MangoHud with the shared
> spdlog before, seems to work.

That should solve the problem, yes!

> However, given what spdlog has in its documentation, I wonder if it
> would be better to default to the static version as before? I think
> the "-fpic" build option would also work for shared linking in
> general? Or does that not work for nheko, which this change was for I
> believe?

Do you mean this:
https://github.com/gabime/spdlog/wiki/How-to-use-spdlog-in-DLLs ?

> I'm not really sure though, nor have a strong opinion, just going
> based on spdlog's info and that some projects (like MangoHud) build
> spdlog as a static library by default when bundling. I'm guessing it
> is for performance reasons, though I don't know if that is realized.

Typically in Guix the libraries are offered as shared objects by
default; and when desirable a static output can be added to which the
static objects are copied.

You could add a static output if you have such a need :-).

Maxim
John Kehayias Feb. 21, 2022, 4:36 p.m. UTC | #3
Hi Maxim,

------- Original Message -------

On Sunday, February 20th, 2022 at 11:11 PM, Maxim Cournoyer wrote:

> Hi John,
>
> John Kehayias john.kehayias@protonmail.com writes:
>
> > Hello,
> >
> > This patch (2/4 build option for spdlog, part of the MangoHud patch
> > series) may be superseded by
> > https://git.savannah.gnu.org/cgit/guix.git/commit/?id=b1542d59606919d0da04914fa6916b85354e2f89
> > (CCing Nicolas, hope that's okay!) I've built MangoHud with the shared
> > spdlog before, seems to work.
>
> That should solve the problem, yes!
>
> > However, given what spdlog has in its documentation, I wonder if it
> > would be better to default to the static version as before? I think
> > the "-fpic" build option would also work for shared linking in
> > general? Or does that not work for nheko, which this change was for I
> > believe?
>
> Do you mean this:
> https://github.com/gabime/spdlog/wiki/How-to-use-spdlog-in-DLLs ?
>

Yes, that's what I meant. I'm not familiar with spdlog, but was just going based on that and seeing packages build a static spdlog to use.

> > I'm not really sure though, nor have a strong opinion, just going
> > based on spdlog's info and that some projects (like MangoHud) build
> > spdlog as a static library by default when bundling. I'm guessing it
> > is for performance reasons, though I don't know if that is realized.
>
> Typically in Guix the libraries are offered as shared objects by
> default; and when desirable a static output can be added to which the
> static objects are copied.
>
> You could add a static output if you have such a need :-).
>

Got it. Personally, it doesn't matter much to me, I'm only assuming projects use the static version due to what upstream says and/or for performance reasons (no idea if that is realized though).

In the interest of moving this forward, I'm definitely fine leaving spdlog as it was updated. We could add a note that upstream and other projects prefer a static build and leave that to add as a TODO. I did take a stab at it some time ago, but it got slightly messy in trying to do it all together (I suppose I could just run the build a second time, but I think it also required modifications to other files to make the static build work separately? I forget now.)

Any thoughts on the imgui details? For me, I'd go for keeping both current (old) dear-imgui as hidden for ogre, adding the one I have here (hidden too? though useful Debian additions in the build) for mangohud, and consolidating to one up to date version once everything can use that. We could use the imgui you added for that, or wait for the more complete Debian build files we are using for dear-imgui right now (the pkg-config, for instance, is helpful).

Finally, the pciutils hardware data pci.ids came up in a new patch: https://issues.guix.gnu.org/54069 I commented on that issue about doing something similar here. I think we can figure out what to do in a core updates change (due to pciutils dependents). In the meantime, a pciutils variant and/or a separate hwdata package would be helpful. Funny enough, this is the last non-trivial change in this patch series, brought up by someone else. I guess the repeated work shows this would be useful though.

Would love to finally get this merged, with whatever changes we decide for imgui and pciutils. WDYT?

Thanks!
John
Maxim Cournoyer Feb. 21, 2022, 5:31 p.m. UTC | #4
Hi John,

John Kehayias <john.kehayias@protonmail.com> writes:

[...]

> Any thoughts on the imgui details? For me, I'd go for keeping both
> current (old) dear-imgui as hidden for ogre, adding the one I have
> here (hidden too? though useful Debian additions in the build) for
> mangohud, and consolidating to one up to date version once everything
> can use that. We could use the imgui you added for that, or wait for
> the more complete Debian build files we are using for dear-imgui right
> now (the pkg-config, for instance, is helpful).

I sorted out the imgui vs dear-imgui mess I had created yesterday by
upgrading our 'ogre' package to its latest version and using imgui 1.86
for it (it wouldn't work with 1.87).

So now we have imgui@1.87 and imgui@1.86 available.  I suggest you try
one of these and if it fails you can try adding yet another public
version for it.

I've looked at the pciutils issue; it seems suboptimal that pciutils
support having the database compressed yet doesn't provide an easy API
to look things from it (or perhaps it does and this is what mangohud
should use?  to be investigated).

I'll try to have a look later into pciutils and whether it offers some
kind of API that users of the DB should use instead of manually parsing
their way through :-).

Thanks,

Maxim
diff mbox series

Patch

From 79f30cf17e88ca50fd8444f1ad34ceb795b1d255 Mon Sep 17 00:00:00 2001
From: John Kehayias <john.kehayias@protonmail.com>
Date: Tue, 4 Jan 2022 16:41:48 -0500
Subject: [PATCH 2/4] gnu: spdlog: Build with '-fpic'.

* gnu/packages/logging.scm (spdlog)[arguments]: Add "-DCMAKE_CXX_FLAGS=-fpic"
to #:configure-flags.
---
 gnu/packages/logging.scm | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/logging.scm b/gnu/packages/logging.scm
index be144e2daa..3c8f67b3ce 100644
--- a/gnu/packages/logging.scm
+++ b/gnu/packages/logging.scm
@@ -8,6 +8,7 @@ 
 ;;; Copyright © 2019 Meiyo Peng <meiyo@riseup.net>
 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
 ;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net>
+;;; Copyright © 2022 John Kehayias <john.kehayias@protonmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -207,7 +208,11 @@  (define-public spdlog
     ;; (gnu packages benchmark) forms a dependency cycle
     (arguments
      '(#:configure-flags
-       (list "-DSPDLOG_BUILD_BENCH=OFF"
+       ;; Typically this library is meant to be compiled statically, see
+       ;; https://github.com/gabime/spdlog/wiki/How-to-use-spdlog-in-DLLs
+       ;; So build with -fpic to allow linking in shared libraries.
+       (list "-DCMAKE_CXX_FLAGS=-fpic"
+             "-DSPDLOG_BUILD_BENCH=OFF"
              "-DSPDLOG_BUILD_TESTS=ON")))
     (home-page "https://github.com/gabime/spdlog")
     (synopsis "Fast C++ logging library")
-- 
2.34.0