Re: Default LDFLAGS in build system - possible problems

2019-02-28 Thread Zdenek Dohnal

On 2/28/19 12:04 PM, Florian Weimer wrote:
> * Zdenek Dohnal:
>
>> I, as Fedora's vim co-maintainer, encountered the issue with default
>> LDFLAGS.
>>
>> I tried to manually run configure script for Vim, with ruby support
>> enabled, but it always failed with error message about missing ncurses
>> (ncurses-devel was installed though). When I looked into config.log, I saw:
>>
>> configure:12069: gcc -o conftest -g -O2  -L. -Wl,-z,relro   -Wl,-z,now
>> -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -fstack-protector
>> -rdynamic -Wl,-export-dynamic  -L/usr/local/lib conftest.c  -lselinux 
>> -lncurses >&5
>> conftest.c: In function 'main':
>> conftest.c:67:26: warning: implicit declaration of function 'tgetent'
>> [-Wimplicit-function-declaration]
>>  char s[1]; int res = tgetent(s, "thisterminaldoesnotexist");
>>   ^~~
>> /usr/bin/ld: /tmp/ccivPtT5.o: relocation R_X86_64_32 against
>> `.rodata.str1.1' can not be used when making a PIE object; recompile
>> with -fPIC
>> /usr/bin/ld: final link failed: nonrepresentable section on output
>> collect2: error: ld returned 1 exit status
> This is a bug in the configure script.  It needs to pass the original
> CFLAGS when compiling link tests.
>
> The command is set correctly initially:
>
> | ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS 
> conftest.$ac_ext $LIBS >&5'
>
> So something appears to reset CFLAGS in the script.

Actually it was like Tom wrote - Fedora specific linker flags were used,
but compiler flags were not. When I added including Fedora specific
compiler flags to configure script, it started to work.

Now let's hope upstream will take it.

Thank you for the hint too though :) .

>
> Thanks,
> Florian
> ___
> devel mailing list -- devel@lists.fedoraproject.org
> To unsubscribe send an email to devel-le...@lists.fedoraproject.org
> Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
> List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
> List Archives: 
> https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org

-- 
Zdenek Dohnal
Associate Software Engineer
Red Hat Czech - Brno TPB-C




signature.asc
Description: OpenPGP digital signature
___
devel mailing list -- devel@lists.fedoraproject.org
To unsubscribe send an email to devel-le...@lists.fedoraproject.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org


Re: Default LDFLAGS in build system - possible problems

2019-02-28 Thread Zdenek Dohnal
On 2/28/19 9:46 AM, Tom Hughes wrote:
> On 28/02/2019 08:30, Zdenek Dohnal wrote:
>
>> I tried to manually run configure script for Vim, with ruby support
>> enabled, but it always failed with error message about missing ncurses
>> (ncurses-devel was installed though). When I looked into config.log,
>> I saw:
>>
>> configure:12069: gcc -o conftest -g -O2  -L. -Wl,-z,relro   -Wl,-z,now
>> -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -fstack-protector
>> -rdynamic -Wl,-export-dynamic  -L/usr/local/lib conftest.c  -lselinux
>> -lncurses >&5
>> conftest.c: In function 'main':
>> conftest.c:67:26: warning: implicit declaration of function 'tgetent'
>> [-Wimplicit-function-declaration]
>>   char s[1]; int res = tgetent(s, "thisterminaldoesnotexist");
>>    ^~~
>> /usr/bin/ld: /tmp/ccivPtT5.o: relocation R_X86_64_32 against
>> `.rodata.str1.1' can not be used when making a PIE object; recompile
>> with -fPIC
>> /usr/bin/ld: final link failed: nonrepresentable section on output
>> collect2: error: ld returned 1 exit status
>>
>> Adding -fPIC actually solved it, but why does the script want it in the
>> first place? Then I ran configure without ruby support enabled and it
>> passed... again from config.log I found out that script wants ruby's
>> LDFLAGS, because script needs them for compilation of ruby support and
>> Ruby LDFLAGS are:
>
> You don't need -fPIC but you need -fPIE at least.
>
> The simple rule is that if you're going to link with Fedora's
> linker flags (which you are doing here) then you need to compile
> with Fedora's compiler flags, 
That was it :) - configure script was using LDFLAGS embedded in ruby,
but it did not use CFLAGS. Thank you for the hint!
> which would have included -fPIE if
> you didn't already specify -fPIE or -fPIC on the command line.
>
> So make sure you tell configure to use $RPM_OPT_FLAGS when
> compiling - if you use %configure and the configure script is
> not too silly then that should happen automatically.
>
> There is a reasonable argument here that the pkgconfig file
> that our ruby package installs is broken, because it embeds
> our linker flags without embedding our compiler flags.
>
> So "pkg-config --libs ruby" tells you to link with those
> flags but "pkg-config --cflags ruby" doesn't give you matching
> compiler flags.
>
> That said, the ruby.pc file may be assuming that it will be
> used for building ruby extensions, which would be .so files
> and hence use -fPIC anyway...
>
> Tom
>
-- 
Zdenek Dohnal
Associate Software Engineer
Red Hat Czech - Brno TPB-C




signature.asc
Description: OpenPGP digital signature
___
devel mailing list -- devel@lists.fedoraproject.org
To unsubscribe send an email to devel-le...@lists.fedoraproject.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org


Re: Default LDFLAGS in build system - possible problems

2019-02-28 Thread Florian Weimer
* Zdenek Dohnal:

> I, as Fedora's vim co-maintainer, encountered the issue with default
> LDFLAGS.
>
> I tried to manually run configure script for Vim, with ruby support
> enabled, but it always failed with error message about missing ncurses
> (ncurses-devel was installed though). When I looked into config.log, I saw:
>
> configure:12069: gcc -o conftest -g -O2  -L. -Wl,-z,relro   -Wl,-z,now
> -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -fstack-protector
> -rdynamic -Wl,-export-dynamic  -L/usr/local/lib conftest.c  -lselinux 
> -lncurses >&5
> conftest.c: In function 'main':
> conftest.c:67:26: warning: implicit declaration of function 'tgetent'
> [-Wimplicit-function-declaration]
>  char s[1]; int res = tgetent(s, "thisterminaldoesnotexist");
>   ^~~
> /usr/bin/ld: /tmp/ccivPtT5.o: relocation R_X86_64_32 against
> `.rodata.str1.1' can not be used when making a PIE object; recompile
> with -fPIC
> /usr/bin/ld: final link failed: nonrepresentable section on output
> collect2: error: ld returned 1 exit status

This is a bug in the configure script.  It needs to pass the original
CFLAGS when compiling link tests.

The command is set correctly initially:

| ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS 
conftest.$ac_ext $LIBS >&5'

So something appears to reset CFLAGS in the script.

Thanks,
Florian
___
devel mailing list -- devel@lists.fedoraproject.org
To unsubscribe send an email to devel-le...@lists.fedoraproject.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org


Re: Default LDFLAGS in build system - possible problems

2019-02-28 Thread Tom Hughes

On 28/02/2019 08:30, Zdenek Dohnal wrote:


I tried to manually run configure script for Vim, with ruby support
enabled, but it always failed with error message about missing ncurses
(ncurses-devel was installed though). When I looked into config.log, I saw:

configure:12069: gcc -o conftest -g -O2  -L. -Wl,-z,relro   -Wl,-z,now
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld -fstack-protector
-rdynamic -Wl,-export-dynamic  -L/usr/local/lib conftest.c  -lselinux
-lncurses >&5
conftest.c: In function 'main':
conftest.c:67:26: warning: implicit declaration of function 'tgetent'
[-Wimplicit-function-declaration]
  char s[1]; int res = tgetent(s, "thisterminaldoesnotexist");
   ^~~
/usr/bin/ld: /tmp/ccivPtT5.o: relocation R_X86_64_32 against
`.rodata.str1.1' can not be used when making a PIE object; recompile
with -fPIC
/usr/bin/ld: final link failed: nonrepresentable section on output
collect2: error: ld returned 1 exit status

Adding -fPIC actually solved it, but why does the script want it in the
first place? Then I ran configure without ruby support enabled and it
passed... again from config.log I found out that script wants ruby's
LDFLAGS, because script needs them for compilation of ruby support and
Ruby LDFLAGS are:


You don't need -fPIC but you need -fPIE at least.

The simple rule is that if you're going to link with Fedora's
linker flags (which you are doing here) then you need to compile
with Fedora's compiler flags, which would have included -fPIE if
you didn't already specify -fPIE or -fPIC on the command line.

So make sure you tell configure to use $RPM_OPT_FLAGS when
compiling - if you use %configure and the configure script is
not too silly then that should happen automatically.

There is a reasonable argument here that the pkgconfig file
that our ruby package installs is broken, because it embeds
our linker flags without embedding our compiler flags.

So "pkg-config --libs ruby" tells you to link with those
flags but "pkg-config --cflags ruby" doesn't give you matching
compiler flags.

That said, the ruby.pc file may be assuming that it will be
used for building ruby extensions, which would be .so files
and hence use -fPIC anyway...

Tom

--
Tom Hughes (t...@compton.nu)
http://compton.nu/
___
devel mailing list -- devel@lists.fedoraproject.org
To unsubscribe send an email to devel-le...@lists.fedoraproject.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org