Bug 1921988 - Compile/link failure when using net-snmp-config --cflags and net-snmp-config --external-libs
Summary: Compile/link failure when using net-snmp-config --cflags and net-snmp-config ...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: net-snmp
Version: 33
Hardware: s390x
OS: Linux
unspecified
high
Target Milestone: ---
Assignee: Josef Ridky
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-01-29 00:44 UTC by Quentin Armitage
Modified: 2021-08-15 01:32 UTC (History)
4 users (show)

Fixed In Version: net-snmp-5.9.1-4.fc34 net-snmp-5.9.1-4.fc33
Doc Type: ---
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-08-15 01:09:59 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Quentin Armitage 2021-01-29 00:44:04 UTC
Description of problem:

Compiling/linking when using the output of $(net-snmp-config --cflags) and $(net-snmp-config --external-libs) produces the following errors:
/usr/bin/ld: /tmp/ccGWfmJB.o: `puts@@GLIBC_2.2' non-PLT reloc for symbol defined in shared library and accessed from executable (rebuild file with -fPIC ?)
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status


Version-Release number of selected component (if applicable):
All recent versions of net-snmp

How reproducible:
Always

Steps to Reproduce:
1.
cat <<EOF >/tmp/hw.c
#include <stdio.h>

int main(int argc, char **argv)
{
        printf("Hello world\n");
}
EOF

2.
gcc $(net-snmp-config --cflags) $(net-snmp-config --external-libs) /tmp/hw{,.c}


Actual results:
Error messages
/usr/bin/ld: /tmp/ccGWfmJB.o: `puts@@GLIBC_2.2' non-PLT reloc for symbol defined in shared library and accessed from executable (rebuild file with -fPIC ?)
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

Expected results:
Compiles/links successfully

Additional info:

This problem does not occur on x86_64.

The problem is caused by the following part of the net-snmp-VER-cflags.patch
diff -urNp a/net-snmp-config.in b/net-snmp-config.in
--- a/net-snmp-config.in        2018-07-18 13:43:12.264426052 +0200
+++ b/net-snmp-config.in        2018-07-18 13:52:06.917089518 +0200
@@ -140,10 +140,10 @@ else
       ;;
     #################################################### compile
     --base-cflags)
-      echo @CFLAGS@ @CPPFLAGS@ -I${NSC_INCLUDEDIR}
+      echo -I${NSC_INCLUDEDIR}
       ;;
     --cflags|--cf*)
-      echo @CFLAGS@ @DEVFLAGS@ @CPPFLAGS@ -I. -I${NSC_INCLUDEDIR}
+      echo @DEVFLAGS@ -I. -I${NSC_INCLUDEDIR}
       ;;
     --srcdir)
       echo $NSC_SRCDIR

because it does not also remove ${NSC_LDFLAGS} from the output of net-snmp-config options --libs, --external-libs, --agent-libs, and --external-agent-libs. This means that the output of net-snmp-config --*-libs includes -specs=/usr/lib/rpm/redhat/redhat-hardened-ld, whereas the output of net-snmp-config --cflags, after the above patch, no longer includes -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1. The consequence of this is that -pie is specified, but -fPIE is not specified.

This problem can been seen on both RHEL and Fedora on all architectures, although with some architectures it does not cause a linker failure.

Comment 1 Fedora Update System 2021-07-30 12:06:43 UTC
FEDORA-2021-542c9d0570 has been submitted as an update to Fedora 34. https://bodhi.fedoraproject.org/updates/FEDORA-2021-542c9d0570

Comment 2 Fedora Update System 2021-07-30 12:06:47 UTC
FEDORA-2021-72e9c8074e has been submitted as an update to Fedora 33. https://bodhi.fedoraproject.org/updates/FEDORA-2021-72e9c8074e

Comment 3 Fedora Update System 2021-08-15 01:09:59 UTC
FEDORA-2021-542c9d0570 has been pushed to the Fedora 34 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 4 Fedora Update System 2021-08-15 01:32:38 UTC
FEDORA-2021-72e9c8074e has been pushed to the Fedora 33 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.