LFS: binutils

Unxmaal

Administrator
Feb 8, 2019
98
60
18
Since I've utterly failed to get pkgsrc to function, I'm trying out a new idea.

I'm following the Linux From Scratch build guides, adjusting it where necessary for IRIX.

I'm using Erno's latest gcc 8.2.0, and I'm trying to set up the /tools environment http://www.linuxfromscratch.org/lfs/view/stable/chapter05/binutils-pass1.html .

I have this environment:

Code:
set +h
umask 022
LC_ALL=POSIX
LFS=/
export MAKEFLAGS='-j 4'
export LC_ALL LFS

#_cdir="gcc-4.4.7"
_cdir="gcc-8.2.0"

export CC=/opt/local/$_cdir/bin/gcc
export CXX=/opt/local/$_cdir/bin/g++
#export CFLAGS="-std=gnu99 -g0 -O2 -mips4"
export CFLAGS="-std=gnu99 -g0 -O0 -mips4"
export CXXFLAGS="$common -FE:eliminate_duplicate_inline_copies:template_in_elf_section $namespace"
export CPPFLAGS="-I/usr/pkg/include"
export LDFLAGS="-Wl,-rpath,/usr/pkg/lib"

export LD_LIBRARY_PATH=/usr/pkg/lib:/opt/local/curl/lib:/opt/local/expat/lib:/opt/local/berkeley-db/lib:/opt/local/gmp/lib:/opt/local/mpc/lib:/o
pt/local/mpfr:/lib:/opt/local/mpfr/lib:/opt/local/$_cdir/lib32:/opt/local/$_cdir/lib
export LIBRARY_PATH=$LD_LIBRARY_PATH
export LD_LIBRARYN32_PATH=/usr/lib32:/usr/pkg/lib
export LD_LIBRARY64_PATH=/usr/lib64
export PATH=/tools/bin:/opt/local/$_cdir/bin::/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bsd:/usr/bin:/usr/nekoware/bin:/usr/nekoware/sbin:/usr/sbi
n:/sbin:/usr/bin/X11

I get the following error:

Code:
libtool: compile:  /opt/local/gcc-8.2.0/bin/gcc -DHAVE_CONFIG_H -I. -I../../bfd "-DBINDIR=\"/tools/bin\"" -DIRIX_CORE -I. -I../../bfd -I../../bfd/../include -DHAVE_mips_elf32_n_be_vec -DHAVE_mips_elf32_n_le_vec -DHAVE_mips_elf32_be_vec -DHAVE_mips_elf32_le_vec -DHAVE_mips_elf64_be_vec -DHAVE_mips_elf64_le_vec -DHAVE_elf64_le_vec -DHAVE_elf64_be_vec -DHAVE_elf32_le_vec -DHAVE_elf32_be_vec -DHAVE_plugin_vec -I/usr/pkg/include -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -I../../bfd/../zlib -std=gnu99 -g0 -O0 -mips4 -MT elf-properties.lo -MD -MP -MF .deps/elf-properties.Tpo -c ../../bfd/elf-properties.c -o elf-properties.o
In file included from ../../bfd/compress.c:21:
../../bfd/compress.c: In function 'bfd_get_full_section_contents':
../../bfd/compress.c:260:43: error: expected ')' before 'PRIx64'
     (_("error: %pB(%pA) is too large (%#" PRIx64 " bytes)"),
                                           ^~~~~~
../../bfd/sysdep.h:222:21: note: in definition of macro '_'
 # define _(String) (String)
                     ^~~~~~
../../bfd/sysdep.h:222:20: note: to match this '('
 # define _(String) (String)
                    ^
../../bfd/compress.c:260:6: note: in expansion of macro '_'
     (_("error: %pB(%pA) is too large (%#" PRIx64 " bytes)"),
      ^
../../bfd/sysdep.h:222:20: warning: conversion lacks type at end of format [-Wformat=]
 # define _(String) (String)
../../bfd/compress.c:260:6: note: in expansion of macro '_'
     (_("error: %pB(%pA) is too large (%#" PRIx64 " bytes)"),
      ^
../../bfd/sysdep.h:222:20: warning: too many arguments for format [-Wformat-extra-args]
 # define _(String) (String)
../../bfd/compress.c:260:6: note: in expansion of macro '_'
     (_("error: %pB(%pA) is too large (%#" PRIx64 " bytes)"),
      ^
make[4]: *** [Makefile:1598: compress.lo] Error 1

Code:
   248    switch (sec->compress_status)
   249      {
   250      case COMPRESS_SECTION_NONE:
   251        if (p == NULL)
   252          {
   253            p = (bfd_byte *) bfd_malloc (sz);
   254            if (p == NULL)
   255              {
   256                /* PR 20801: Provide a more helpful error message.  */
   257                if (bfd_get_error () == bfd_error_no_memory)
   258                  _bfd_error_handler
   259                    /* xgettext:c-format */
   260                    (_("error: %pB(%pA) is too large (%#" PRIx64 " bytes)"),
   261                    abfd, sec, (uint64_t) sz);
   262                return FALSE;
   263              }
   264          }
   265
   266        if (!bfd_get_section_contents (abfd, sec, p, 0, sz))
   267          {
   268            if (*ptr != p)
   269              free (p);
   270            return FALSE;
   271          }
   272        *ptr = p;
   273        return TRUE;

Any suggestions?
 

hammy

Active member
Jun 1, 2019
108
68
28
UK
Are you trying to cross compile or are you building natively on irix? What's your toolchain version (mipspro 7.4.4m?)

If you "grep -r PRIx64 /usr/include" you'll see it's defined in /usr/include/inttypes.h - and in that header it's sitting inside the "else" of an #if !defined(__c99) section.

So if I had to guess for some reason the compiler isn't setting up the __c99 define so that section isn't being used and PRIx64 doesn't get set to something.

You can check if this is the case by putting "#define __c99" right at the top of the bfd/compress.c file - this isn't a proper fix, but will let us see if that's the source of your woes.

D
 

Unxmaal

Administrator
Feb 8, 2019
98
60
18
I'm not cross-compiling. I'm just referencing LFS as a guide for compiling things on IRIX -- what order to compile in, and so forth.

Adding the define shows this error

Code:
libtool: compile:  /opt/local/gcc-8.2.0/bin/gcc -DHAVE_CONFIG_H -I. -I../../bfd "-DBINDIR=\"/tools/bin\"" -DIRIX_CORE -I. -I../../bfd -I../../bf
d/../include -DHAVE_mips_elf32_n_be_vec -DHAVE_mips_elf32_n_le_vec -DHAVE_mips_elf32_be_vec -DHAVE_mips_elf32_le_vec -DHAVE_mips_elf64_be_vec -D
HAVE_mips_elf64_le_vec -DHAVE_elf64_le_vec -DHAVE_elf64_be_vec -DHAVE_elf32_le_vec -DHAVE_elf32_be_vec -DHAVE_plugin_vec -I/usr/pkg/include -W -
Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -I../../bfd/../zlib -std=gnu99 -g0 -O0 -mips4 -MT merge.lo -MD -MP -
MF .deps/merge.Tpo -c ../../bfd/merge.c -o merge.o
../../bfd/compress.c:26: warning: "__c99" redefined
 #define __c99
And it then fails in the same way.

Referencing https://wtf.hijacked.us/wiki/index.php/Pkgsrc_on_IRIX , I added the PRIx64 defines in bfd/config.h, make clean ; make , and it worked.
 

hammy

Active member
Jun 1, 2019
108
68
28
UK
I'm not cross-compiling. I'm just referencing LFS as a guide for compiling things on IRIX -- what order to compile in, and so forth.

Adding the define shows this error

...

And it then fails in the same way.

Referencing https://wtf.hijacked.us/wiki/index.php/Pkgsrc_on_IRIX , I added the PRIx64 defines in bfd/config.h, make clean ; make , and it worked.
Right, so that means the compiler is at least defining the right thing. Do you have PRIx64 defines inside /usr/include/inttypes.h? What does "grep PRIx64 /usr/include/*.h" show you?

The reason I ask is that older developer toolchains (<=7.3 I think) don't include the C99 header tweaks you'd need to have these extra defines.

You can add the defines locally to the package - but honestly that's hiding the real problem and it'll come up in other packages.

One thing you could do if you reverse out your manual changes - re-run the failing compilation manually to spit out the output after preprocessing:

Code:
/opt/local/gcc-8.2.0/bin/gcc -DHAVE_CONFIG_H -I. -I../../bfd "-DBINDIR=\"/tools/bin\"" -DIRIX_CORE -I. -I../../bfd -I../../bfd/../include -DHAVE_mips_elf32_n_be_vec -DHAVE_mips_elf32_n_le_vec -DHAVE_mips_elf32_be_vec -DHAVE_mips_elf32_le_vec -DHAVE_mips_elf64_be_vec -DHAVE_mips_elf64_le_vec -DHAVE_elf64_le_vec -DHAVE_elf64_be_vec -DHAVE_elf32_le_vec -DHAVE_elf32_be_vec -DHAVE_plugin_vec -I/usr/pkg/include -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -I../../bfd/../zlib -std=gnu99 -g0 -O0 -mips4 -MT merge.lo -MD -MP -MF .deps/merge.Tpo -c ../../bfd/merge.c -E 1>merge.preprocessed 2>&1
This will create a file "merge.preprocessed" where we should be able to see which files it is including, and what they are defining (or not). Post the output up on pastebin or some other text posting thing and I'll take a look.

Care: You'll need to run the above making sure you've got the same environment flags etc to properly reproduce it.
 

About us

  • Silicon Graphics User Group (SGUG) is a community for users, developers, and admirers of Silicon Graphics (SGI) products. We aim to be a friendly hobbyist community for discussing all aspects of SGIs, including use, software development, the IRIX Operating System, and troubleshooting, as well as facilitating hardware exchange.

User Menu