Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: fix and simplify NetSNMP compilation #1608

Closed

Conversation

vincentbernat
Copy link
Contributor

First, this reverts changes made in #416 (commit 328ec28). With
lldpd, I don't use --netsnmp-agent-libs --external-libs and I never
had an issue with Ubuntu 14.04. From my understanding, the code to fix
mangle NETSNMP_LIBS to fix issues with Fedora is then not needed
anymore because the issue appears only because of --external-libs,
so the code can be removed as well. This was added in #858 (commit
057c279).

Then, this also reverts changes introduced in #1262, notably commit
63fe1f4. Seperating CPPFLAGS from CFLAGS also reorder some flags,
making headers in /usr/lib/*/perl/*/CORE used before the ones in
lib/. This happens for parser.h and leads to this error when
NetSNMP is linked to libperl. This happens with out-of-tree builds
when -I$(srcdir)/../include -I$(srcdir)/../../lib is appended too
late.

In file included from ../../../keepalived/core/main.c:54:
/usr/lib/x86_64-linux-gnu/perl/5.30/CORE/parser.h:15:5: error: unknown type name ‘YYSTYPE’
   15 |     YYSTYPE val;    /* semantic value */
      |     ^~~~~~~

After investigating a bit, I have a less invasive fix to propose. I'll send another one with this fix. I keep this PR here to maybe have a change to discuss the first change (and check everything passes in Travis).

First, this reverts changes made in acassen#416 (commit 328ec28). With
lldpd, I don't use `--netsnmp-agent-libs --external-libs` and I never
had an issue with Ubuntu 14.04. From my understanding, the code to fix
mangle `NETSNMP_LIBS` to fix issues with Fedora is then not needed
anymore because the issue appears only because of `--external-libs`,
so the code can be removed as well. This was added in acassen#858 (commit
057c279).

Then, this also reverts changes introduced in acassen#1262, notably commit
63fe1f4. Seperating CPPFLAGS from CFLAGS also reorder some flags,
making headers in `/usr/lib/*/perl/*/CORE` used before the ones in
`lib/`. This happens for `parser.h` and leads to this error when
NetSNMP is linked to libperl. This happens with out-of-tree builds
when `-I$(srcdir)/../include -I$(srcdir)/../../lib` is appended too
late.

```
In file included from ../../../keepalived/core/main.c:54:
/usr/lib/x86_64-linux-gnu/perl/5.30/CORE/parser.h:15:5: error: unknown type name ‘YYSTYPE’
   15 |     YYSTYPE val;    /* semantic value */
      |     ^~~~~~~
```
@vincentbernat
Copy link
Contributor Author

I have pushed a less invasive fix in #1609. However, I still think the first change of this PR (not using --external-libs is worth discussing).

@pqarmitage
Copy link
Collaborator

On Fedora, the output of net-snmp-config --agent-libs is:
-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -lm -L/usr/lib64 -lnetsnmpmibs -lsensors -ldl -lrpm -lrpmio -lnetsnmpagent -Wl,--enable-new-dtags -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -lnetsnmp -lssl -lssl -lcrypto -lm

/usr/lib/rpm/redhat/redhat-hardened-ld is not installed by default, nor is it installed by any of the packages that keepalived needs in order to build, so it seems that #858 (commit 057c279) is still needed. Also, -lrpm -lrpmio seem unnecessary, and these are not included with --external-libs or --netsnmp-agent-libs.

So I think, at least for RedHat based systems, checking for the -specs= files is necessary, and using --external-libs and --netsnmp-agent-libsis better than--agent-libs`, and if it works for other distros I am included to leave it as it is.

@vincentbernat
Copy link
Contributor Author

OK, I just read the bugzilla. I never noticed the problem as I suppose my build environment (OBS) is including the missing package. https://build.opensuse.org/public/build/home:vbernat/Fedora_33/x86_64/lldpd/_log

NetSNMP upstream is difficult to work with. The problem around the invasive flags needed to build an agent lasts forever and any solution is rejected.

@pqarmitage
Copy link
Collaborator

I've just had a look at https://build.opensuse.org/public/build/home:vbernat/Fedora_33/x86_64/lldpd/_log and indeed rpm-libs and redhat-rpm-config appear to be installed, which are the two packages that provide the extra files.

@pqarmitage pqarmitage closed this Nov 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants