gcc4.4 build error on Centos7

General support questions
User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: gcc4.4 build error on Centos7

Post by TrevorH » 2017/10/10 12:14:06

And the answers to your questions are likely in the output from readelf but you need to find them.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

User avatar
jlehtone
Posts: 4530
Joined: 2007/12/11 08:17:33
Location: Finland

Re: gcc4.4 build error on Centos7

Post by jlehtone » 2017/10/10 16:41:07

vyshnav wrote:Can you please tell which version of gcc you are used for compiling.
My post right before yours had such details.
vyshnav wrote:Our binary which was compiled on centos 6 is of size 900MB. When i compile in Centos7 the binary size is 1.6GB. If i strip the binary, the resulting file is only 50MB ,this is the actual scenario.
That is scary size for a binary and very impressive strip.
How much does strip leave on the CentOS 6?

It should be easy to do the strip by default with the build tools.

vyshnav
Posts: 60
Joined: 2017/09/12 03:37:54

Re: gcc4.4 build error on Centos7

Post by vyshnav » 2017/10/11 06:14:30

jlehtone wrote:Deja vu: viewtopic.php?f=47&t=64179

Lets play (the gcc-6.3 is from devtoolset-6):
# cat hello.c

Code: Select all

#include <stdio.h>

int main() {
  int foo = 42;
  printf( "%4d\n", foo );
  return 0;
}

Code: Select all

# cat /etc/centos-release 
CentOS Linux release 7.4.1708 (Core)

# gcc --version
gcc (GCC) 6.3.1 20170216 (Red Hat 6.3.1-3)
# gcc -Os -Wall -Wextra -o foo-7-63 hello.c

# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16)
# gcc -Os -Wall -Wextra -o foo-7-48 hello.c

# gcc44 --version
gcc44 (GCC) 4.4.7 20120313 (Red Hat 4.4.7-8)
# gcc44 -Os -Wall -Wextra -o foo-7-44 hello.c

Code: Select all

# cat /etc/centos-release
CentOS release 6.9 (Final)

# gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18)
# gcc -Os -Wall -Wextra -o foo-6-44 hello.c

# gcc --version
gcc (GCC) 6.3.1 20170216 (Red Hat 6.3.1-3)
# gcc -Os -Wall -Wextra -o foo-6-63 hello.c

Code: Select all

# ls -gG foo*
-rwxr-xr-x. 1 6411 Oct  9 13:02 foo-6-44
-rwxr-xr-x. 1 8480 Oct  9 13:03 foo-6-63
-rwxr-xr-x. 1 8440 Oct  9 13:09 foo-7-44
-rwxr-xr-x. 1 8520 Oct  9 12:50 foo-7-48
-rwxr-xr-x. 1 8480 Oct  9 12:51 foo-7-63

# strip foo*
# ls -gG foo*
-rwxr-xr-x. 1 4232 Oct  9 13:04 foo-6-44
-rwxr-xr-x. 1 6272 Oct  9 13:04 foo-6-63
-rwxr-xr-x. 1 6272 Oct  9 13:09 foo-7-44
-rwxr-xr-x. 1 6240 Oct  9 12:55 foo-7-48
-rwxr-xr-x. 1 6344 Oct  9 12:55 foo-7-63
Interestingly, the 6.3 produces same size on both platforms, but strips differently.

The 4.4 is smaller on C6 than C7, before and after stripping.
However, the object files save same size:

Code: Select all

C7# gcc44 -Os -Wall -Wextra -c hello.c
C7# ls -gG hello.o
-rw-r--r--. 1 1488 Oct  9 13:22 hello.o

C6# gcc -Os -Wall -Wextra -c hello.c
C6# ls -gG hello.o
-rw-r--r--. 1 1488 Oct  9 13:23 hello.o
Like TrevorH wrote, the compiler is innocent here.


[edit]

Code: Select all

# readelf -h foo-6-44
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x4003e0
  Start of program headers:          64 (bytes into file)
  Start of section headers:          2440 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         8
  Size of section headers:           64 (bytes)
  Number of section headers:         28
  Section header string table index: 27

# readelf -h foo-7-44
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x400450
  Start of program headers:          64 (bytes into file)
  Start of section headers:          4480 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         9
  Size of section headers:           64 (bytes)
  Number of section headers:         28
  Section header string table index: 27
The Start of section headers is different between the two.
can you please tell ,which option in readelf is increasing the size of executable? this start of section header will cause the size difference ?

User avatar
jlehtone
Posts: 4530
Joined: 2007/12/11 08:17:33
Location: Finland

Re: gcc4.4 build error on Centos7

Post by jlehtone » 2017/10/11 08:37:45

I don't speak Elvish. I just did read
man readelf
enough to get some output. Besides,
readelf - Displays information about ELF files.
readelf apparently reads, shows, displays.

As TrevorH has written, it should be the linker that constructs the ELF binary.
It is the new linker that includes something new.
Something in the program headers, apparently.
The readelf might be able to tell what, but not why.


You did not tell how much strip reduces size on the other system of yours.

vyshnav
Posts: 60
Joined: 2017/09/12 03:37:54

Re: gcc4.4 build error on Centos7

Post by vyshnav » 2017/10/11 08:53:10

jlehtone wrote:I don't speak Elvish. I just did read
man readelf
enough to get some output. Besides,
readelf - Displays information about ELF files.
readelf apparently reads, shows, displays.

As TrevorH has written, it should be the linker that constructs the ELF binary.
It is the new linker that includes something new.
Something in the program headers, apparently.
The readelf might be able to tell what, but not why.


You did not tell how much strip reduces size on the other system of yours.
Sorry i didnt understand first.
gcc4.4.7 in centos6.PNG
gcc4.4.7 in centos6.PNG (23.76 KiB) Viewed 1921 times
this is the output I'm getting after striping in centos6

User avatar
jlehtone
Posts: 4530
Joined: 2007/12/11 08:17:33
Location: Finland

Re: gcc4.4 build error on Centos7

Post by jlehtone » 2017/10/11 08:59:52

Our binary which was compiled on centos 6 is of size 900MB.
Do you really strip that to 4.2K?


PS. Why do you post bitmaps? Images are larger than plain text.

vyshnav
Posts: 60
Joined: 2017/09/12 03:37:54

Re: gcc4.4 build error on Centos7

Post by vyshnav » 2017/10/11 09:10:41

jlehtone wrote:
Our binary which was compiled on centos 6 is of size 900MB.
Do you really strip that to 4.2K?


This is the output of "Helloworld" program , actuallly i dont want to strip in centos6 . When i compile in centos7 (gcc4.8) i should get a binary of size that is same as that of centos 6(gcc4.4)

User avatar
jlehtone
Posts: 4530
Joined: 2007/12/11 08:17:33
Location: Finland

Re: gcc4.4 build error on Centos7

Post by jlehtone » 2017/10/11 12:22:38

vyshnav wrote:This is the output of "Helloworld" program , actuallly i dont want to strip in centos6 . When i compile in centos7 (gcc4.8) i should get a binary of size that is same as that of centos 6(gcc4.4)
You want to strip in centos 6. Not the used binary, but a temporary copy of it. You want to know the result, for listing differences between the system.

Who says that CentOS 6 binaries should have same size as CentOS 7 binaries?
You would like to have same size.


The linker has rebased from 2.20 into 2.25:

Code: Select all

# rpm -qf $(which ld)

C6# rpm -q binutils
binutils-2.20.51.0.2-5.47.el6_9.1.x86_64

C7# rpm -qf /usr/bin/ld
binutils-2.25.1-32.base.el7_4.1.x86_64

vyshnav
Posts: 60
Joined: 2017/09/12 03:37:54

Re: gcc4.4 build error on Centos7

Post by vyshnav » 2017/10/12 04:42:06

jlehtone wrote:
vyshnav wrote:This is the output of "Helloworld" program , actuallly i dont want to strip in centos6 . When i compile in centos7 (gcc4.8) i should get a binary of size that is same as that of centos 6(gcc4.4)
You want to strip in centos 6. Not the used binary, but a temporary copy of it. You want to know the result, for listing differences between the system.

Who says that CentOS 6 binaries should have same size as CentOS 7 binaries?
You would like to have same size.


The linker has rebased from 2.20 into 2.25:

Code: Select all

# rpm -qf $(which ld)

C6# rpm -q binutils
binutils-2.20.51.0.2-5.47.el6_9.1.x86_64

C7# rpm -qf /usr/bin/ld
binutils-2.25.1-32.base.el7_4.1.x86_64
I want to have same size in both centos 6 and centos 7

vyshnav
Posts: 60
Joined: 2017/09/12 03:37:54

Re: gcc4.4 build error on Centos7

Post by vyshnav » 2017/10/30 07:07:21

vyshnav wrote:
jlehtone wrote:
vyshnav wrote:This is the output of "Helloworld" program , actuallly i dont want to strip in centos6 . When i compile in centos7 (gcc4.8) i should get a binary of size that is same as that of centos 6(gcc4.4)
You want to strip in centos 6. Not the used binary, but a temporary copy of it. You want to know the result, for listing differences between the system.

Who says that CentOS 6 binaries should have same size as CentOS 7 binaries?
You would like to have same size.


The linker has rebased from 2.20 into 2.25:

Code: Select all

# rpm -qf $(which ld)

C6# rpm -q binutils
binutils-2.20.51.0.2-5.47.el6_9.1.x86_64

C7# rpm -qf /usr/bin/ld
binutils-2.25.1-32.base.el7_4.1.x86_64
I want to have same size in both centos 6 and centos 7

Can i replace this new binutils package with old to solve my issue?? is it reduce the size of binary ?

Post Reply