Bug 1197009 - Opal fails to build due to -Wl,-z,relro
Summary: Opal fails to build due to -Wl,-z,relro
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: opal
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Peter Robinson
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-02-27 10:44 UTC by Milan Crha
Modified: 2015-03-09 08:34 UTC (History)
6 users (show)

Fixed In Version: ptlib-2.10.10-10.fc22
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-03-09 08:34:11 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
opal.patch (1.43 KB, patch)
2015-03-02 13:22 UTC, Milan Crha
no flags Details | Diff

Description Milan Crha 2015-02-27 10:44:14 UTC
Currently opal fails to build in rawhide:
http://koji.fedoraproject.org/koji/taskinfo?taskID=9085893

From its log the reason is:
   checking size of short... 0
   checking size of int... 0
   checking size of long... 0
   checking size of long long... 0

Digging further in the config.log:
> /usr/bin/ld: /tmp/ccjDCDU2.o: relocation R_X86_64_32 against `.rodata' can
> not be used when making a shared object; recompile with -fPIC
> /tmp/ccjDCDU2.o: error adding symbols: Bad value
> collect2: error: ld returned 1 exit status

but this is called in configure.ac (through opal.m4) as:

          AC_CHECK_SIZEOF(short)
          AC_CHECK_SIZEOF(int)
          AC_CHECK_SIZEOF(long)
          AC_CHECK_SIZEOF(long long)

thus something not completely under my control, if I understand it correctly.

That is, what can one do make this work again?
How many other projects can be affected by this change?

configure:6962: checking size of short
configure:6967: gcc -o conftest   -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -DP_64BIT -DPTRACING=1 -D_REENTRANT -D_GNU_SOURCE=1 -D_REENTRANT -fno-exceptions -I/usr/include/SDL  conftest.c  >&5
/usr/bin/ld: /tmp/ccjDCDU2.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/tmp/ccjDCDU2.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
configure:6967: $? = 1
configure: program exited with status 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define STDC_HEADERS 1
| #define OPAL_MAJOR 3
| #define OPAL_MINOR 10
| #define OPAL_BUILD 10
| #define OPAL_VERSION "3.10.10"
| #define OPAL_PLUGIN_DIR "/usr/lib64/opal-3.10.10"
| #define OPAL_PTLIB_SSL 1
| #define OPAL_PTLIB_ASN 1
| #define OPAL_PTLIB_EXPAT 1
| #define OPAL_PTLIB_VIDEO 1
| #define OPAL_PTLIB_WAVFILE 1
| #define OPAL_PTLIB_VXML 1
| #define OPAL_PTLIB_DTMF 1
| #define OPAL_PTLIB_LDAP 1
| #define OPAL_PTLIB_DNS 1
| #define OPAL_PTLIB_AUDIO 1
| #define OPAL_PTLIB_CONFIG_FILE 1
| #define OPAL_PTLIB_SSL_AES 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_DLFCN_H 1
| /* end confdefs.h.  */
| #include <stdio.h>
| #ifdef HAVE_SYS_TYPES_H
| # include <sys/types.h>
| #endif
| #ifdef HAVE_SYS_STAT_H
| # include <sys/stat.h>
| #endif
| #ifdef STDC_HEADERS
| # include <stdlib.h>
| # include <stddef.h>
| #else
| # ifdef HAVE_STDLIB_H
| #  include <stdlib.h>
| # endif
| #endif
| #ifdef HAVE_STRING_H
| # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
| #  include <memory.h>
| # endif
| # include <string.h>
| #endif
| #ifdef HAVE_STRINGS_H
| # include <strings.h>
| #endif
| #ifdef HAVE_INTTYPES_H
| # include <inttypes.h>
| #endif
| #ifdef HAVE_STDINT_H
| # include <stdint.h>
| #endif
| #ifdef HAVE_UNISTD_H
| # include <unistd.h>
| #endif
| static long int longval () { return (long int) (sizeof (short)); }
| static unsigned long int ulongval () { return (long int) (sizeof (short)); }
| #include <stdio.h>
| #include <stdlib.h>
| int
| main ()
| {
| 
|   FILE *f = fopen ("conftest.val", "w");
|   if (! f)
|     return 1;
|   if (((long int) (sizeof (short))) < 0)
|     {
|       long int i = longval ();
|       if (i != ((long int) (sizeof (short))))
| 	return 1;
|       fprintf (f, "%ld", i);
|     }
|   else
|     {
|       unsigned long int i = ulongval ();
|       if (i != ((long int) (sizeof (short))))
| 	return 1;
|       fprintf (f, "%lu", i);
|     }
|   /* Do not output a trailing newline, as this causes \r\n confusion
|      on some platforms.  */
|   return ferror (f) || fclose (f) != 0;
| 
|   ;
|   return 0;
| }
configure:6981: result: 0

Comment 1 Jakub Jelinek 2015-02-27 10:50:01 UTC
gcc -o conftest   -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -DP_64BIT -DPTRACING=1 -D_REENTRANT -D_GNU_SOURCE=1 -D_REENTRANT -fno-exceptions -I/usr/include/SDL  conftest.c
is obviously bogus.  If you use -specs=/usr/lib/rpm/redhat/redhat-hardened-ld for linking, you need to use also -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
for compilation, and as in this case you are compiling and linking with the same command, you need both.
Thus, the bug is probably somewhere on the package side, CFLAGS not being used properly, or on the spec side, LDFLAGS propagated to the package but %{optflags} aka $RPM_OPT_FLAGS not.

Comment 2 Milan Crha 2015-03-02 10:44:09 UTC
Do you think that a very similar error from a build of evolution-data-server which worked flawlessly for years is also affected by the same issue as the opal build? The related bits in evolution-data-server configure.ac begin
at [1], while the libdb failing part is at [2]. This is with the current rawhide latest libdb installed [3].

[1] https://git.gnome.org/browse/evolution-data-server/tree/configure.ac#n627
[2] https://git.gnome.org/browse/evolution-data-server/tree/configure.ac#n646
[3] http://koji.fedoraproject.org/koji/buildinfo?buildID=613792

configure:21475: checking Berkeley DB
configure:21490: gcc -o conftest -I/usr/include -I/usr/include/et -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,--no-undefined conftest.c -L/usr/lib -ldb >&5
/usr/bin/ld: /tmp/ccDPU2dQ.o: relocation R_X86_64_PC32 against undefined symbol `db_create' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
configure:21490: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "evolution-data-server"
| #define PACKAGE_TARNAME "evolution-data-server"
| #define PACKAGE_VERSION "3.15.91"
| #define PACKAGE_STRING "evolution-data-server 3.15.91"
| #define PACKAGE_BUGREPORT "http://bugzilla.gnome.org/enter_bug.cgi?product=Evolution-Data-Server"
| #define PACKAGE_URL ""
| #define PACKAGE "evolution-data-server"
| #define VERSION "3.15.91"
| #define BASE_VERSION "3.16"
| #define API_VERSION "1.2"
| #define ADDRESS_BOOK_DBUS_SERVICE_NAME "org.gnome.evolution.dataserver.AddressBook9"
| #define CALENDAR_DBUS_SERVICE_NAME "org.gnome.evolution.dataserver.Calendar7"
| #define SOURCES_DBUS_SERVICE_NAME "org.gnome.evolution.dataserver.Sources4"
| #define USER_PROMPTER_DBUS_SERVICE_NAME "org.gnome.evolution.dataserver.UserPrompter0"
| #define GETTEXT_PACKAGE "evolution-data-server-3.16"
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_DLFCN_H 1
| #define LT_OBJDIR ".libs/"
| #define HAVE_SYS_WAIT_H 1
| #define HAVE_ALLOCA_H 1
| #define HAVE_ALLOCA 1
| #define HAVE_FSYNC 1
| #define HAVE_STRPTIME 1
| #define HAVE_STRTOK_R 1
| #define HAVE_NL_LANGINFO 1
| #define HAVE_GTK 1
| #define BUILD_EXAMPLES 1
| #define HAVE_GOA 1
| #define ENABLE_BACKEND_PER_PROCESS 1
| #define HAVE_REGEXEC 1
| /* end confdefs.h.  */
| #include <db.h>
| int
| main ()
| {
| db_create(NULL, NULL, 0)
|   ;
|   return 0;
| }
configure:21494: error: Cannot find libdb

Comment 3 Milan Crha 2015-03-02 10:51:57 UTC
(In reply to Milan Crha from comment #2)
> Do you think that a very similar error from a build of evolution-data-server
> which worked flawlessly for years is also affected by the same issue as the
> opal build?

Never mind, I can fix in in configure.ac of the evolution-data-server.

Comment 4 Marek Polacek 2015-03-02 12:27:50 UTC
That looks like the same issue.

Yes, it might have worked before (with gcc 4.? or gcc 5 configured against linker without HAVE_LD_PIE_COPYRELOC), but that was a luck.  You cannot link -fpie/-fPIE compiled .o into an .so.

Comment 5 Peter Robinson 2015-03-02 12:38:43 UTC
(In reply to Marek Polacek from comment #4)
> That looks like the same issue.
> 
> Yes, it might have worked before (with gcc 4.? or gcc 5 configured against
> linker without HAVE_LD_PIE_COPYRELOC), but that was a luck.  You cannot link
> -fpie/-fPIE compiled .o into an .so.

Can you provide details how you'd fix this in the package?

Comment 6 Milan Crha 2015-03-02 13:22:32 UTC
Created attachment 997077 [details]
opal.patch

They did unset CFLAGS and LIBS before running AC_CHECK_SIZEOF(), which broke with the update of gcc and/or the build option change. This patch fixes it. Ideally, only the chunk for opal.m4 should be enough, but regenerating automake files fails in my rawhide, thus I rather patched the two "affected" configure files directly. Scratch build succeeded, as can be seen here:
http://koji.fedoraproject.org/koji/taskinfo?taskID=9118836

Comment 7 Marek Polacek 2015-03-02 13:35:22 UTC
(In reply to Peter Robinson from comment #5)
> Can you provide details how you'd fix this in the package?

See Comment 1.  I'd look if CFLAGS/CXXFLAGS aren't overrided globally to -fpie/-fPIE, which won't work.  This has been the case for openssh package -- and then the build failed with new GCC because of this very issue.

Comment 8 Fedora Update System 2015-03-02 16:52:43 UTC
ptlib-2.10.10-10.fc22,opal-3.10.10-7.fc22,ekiga-4.0.1-17.fc22 has been submitted as an update for Fedora 22.
https://admin.fedoraproject.org/updates/ptlib-2.10.10-10.fc22,opal-3.10.10-7.fc22,ekiga-4.0.1-17.fc22

Comment 9 Fedora Update System 2015-03-02 23:07:36 UTC
Package ptlib-2.10.10-10.fc22, opal-3.10.10-7.fc22, ekiga-4.0.1-17.fc22:
* should fix your issue,
* was pushed to the Fedora 22 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing ptlib-2.10.10-10.fc22 opal-3.10.10-7.fc22 ekiga-4.0.1-17.fc22'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2015-2962/ptlib-2.10.10-10.fc22,opal-3.10.10-7.fc22,ekiga-4.0.1-17.fc22
then log in and leave karma (feedback).

Comment 10 Fedora Update System 2015-03-09 08:34:11 UTC
ptlib-2.10.10-10.fc22, opal-3.10.10-7.fc22, ekiga-4.0.1-17.fc22 has been pushed to the Fedora 22 stable repository.  If problems still persist, 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.