Thread: BUG #1999: contrib/spi doesn't receive the configured CFLAGS

BUG #1999: contrib/spi doesn't receive the configured CFLAGS

From
"Seneca Cunningham"
Date:
The following bug has been logged online:

Bug reference:      1999
Logged by:          Seneca Cunningham
Email address:      scunning@ca.afilias.info
PostgreSQL version: 8.1beta4
Operating system:   AIX 5.3
Description:        contrib/spi doesn't receive the configured CFLAGS
Details:

After configuring and building postgres with the CFLAGS necessary to build
postgres using the 64-bit AIX ABI with gcc4, gmake check fails during the
build of contrib/spi due to it not receiving the required CFLAGS.

Sample session:
$ cd postgresql-8.1beta4
$ export OBJECT_MODE=64
$ CFLAGS="-maix64 -Wl,-bbigtoc" ./configure
--prefix=/opt/dbs/pgsql81b4-afilias-AIX53-2005-10-25
--with-includes=/opt/freeware/include --enable-debug --enable-thread-safety
--with-libraries=/opt/freeware/lib --enable-casert
[...]
$ gmake
[...]
All of PostgreSQL successfully made. Ready to install.
$ gmake -C src/test check
gmake[1]: Entering directory
`/opt/test/postgres/postgresql-8.1beta4/src/test'
gmake -C regress check
gmake[2]: Entering directory
`/opt/test/postgres/postgresql-8.1beta4/src/test/regress'
gmake -C ../../../contrib/spi refint.so autoinc.so
gmake[3]: Entering directory
`/opt/test/postgres/postgresql-8.1beta4/contrib/spi'
gcc -maix64 -Wl,-bbigtoc -Wall -Wmissing-prototypes -Wpointer-arith -Winline
-Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing
-DREFINT_VERBOSE -I. -I../../src/include -I/opt/freeware/include  -c -o
refint.o refint.c
gcc: -bbigtoc: linker input file unused because linking not done
../../src/backend/port/aix/mkldexport.sh refint.o > refint.exp
Making shared library refint.so from refint.o, refint.exp and postgres.imp
gcc -L../../src/port -L/opt/freeware/lib  -Wl,-bnoentry -Wl,-H512
-Wl,-bM:SRE -o refint.so refint.o -Wl,-bI:../../src/backend/postgres.imp
-Wl,-bE:refint.exp  -L../../src/port -lpgport
Assembler:
/tmp//cc0wG03u.s: line 8: 1252-191 Only .llong should be used for
relocatable expressions.
/tmp//cc0wG03u.s: line 9: 1252-191 Only .llong should be used for
relocatable expressions.
/tmp//cc0wG03u.s: line 10: 1252-191 Only .llong should be used for
relocatable expressions.
/tmp//cc0wG03u.s: line 11: 1252-191 Only .llong should be used for
relocatable expressions.
/tmp//cc0wG03u.s: line 12: 1252-191 Only .llong should be used for
relocatable expressions.
/tmp//cc0wG03u.s: line 13: 1252-191 Only .llong should be used for
relocatable expressions.
/tmp//cc0wG03u.s: line 14: 1252-191 Only .llong should be used for
relocatable expressions.
/tmp//cc0wG03u.s: line 15: 1252-191 Only .llong should be used for
relocatable expressions.
/tmp//cc0wG03u.s: line 16: 1252-191 Only .llong should be used for
relocatable expressions.
/tmp//cc0wG03u.s: line 17: 1252-191 Only .llong should be used for
relocatable expressions.
/tmp//cc0wG03u.s: line 30: 1252-191 Only .llong should be used for
relocatable expressions.
/tmp//cc0wG03u.s: line 62: 1252-191 Only .llong should be used for
relocatable expressions.
/tmp//cc0wG03u.s: line 103: 1252-191 Only .llong should be used for
relocatable expressions.
/tmp//cc0wG03u.s: line 171: 1252-191 Only .llong should be used for
relocatable expressions.
collect2: gcc returned 1 exit status
gmake[3]: *** [refint.so] Error 1
rm refint.o refint.exp
gmake[3]: Leaving directory
`/opt/test/postgres/postgresql-8.1beta4/contrib/spi'
gmake[2]: *** [all-spi] Error 2
gmake[2]: Leaving directory
`/opt/test/postgres/postgresql-8.1beta4/src/test/regress'
gmake[1]: *** [check] Error 2
gmake[1]: Leaving directory
`/opt/test/postgres/postgresql-8.1beta4/src/test'
gmake: *** [check] Error 2
$
---- end of sample session

The errors from the assembler are the ones that occur when IBM's assembler
is in 64-bit mode and it has been passed output from gcc generating 32-bit
code, its default mode.  This error would not occur if gcc were passed
-maix64.

-bash-2.05b$ gcc -v
Using built-in specs.
Target: powerpc-ibm-aix5.3.0.0
Configured with: /opt/src/gcc4/gcc-4.0.1/configure --prefix=/opt/dbs/gcc4
--enable-languages=c,c++
Thread model: aix
gcc version 4.0.1
-bash-2.05b$ as -v
as V5.3
^C-bash-2.05b$ oslevel -r
5300-03

Re: BUG #1999: contrib/spi doesn't receive the configured CFLAGS

From
Tom Lane
Date:
"Seneca Cunningham" <scunning@ca.afilias.info> writes:
> $ cd postgresql-8.1beta4
> $ export OBJECT_MODE=64
> $ CFLAGS="-maix64 -Wl,-bbigtoc" ./configure
> --prefix=/opt/dbs/pgsql81b4-afilias-AIX53-2005-10-25
> --with-includes=/opt/freeware/include --enable-debug --enable-thread-safety
> --with-libraries=/opt/freeware/lib --enable-casert

This is your error.  -Wl,-bbigtoc is not a compiler flag, it's a linker
flag, and hence should be specified in LDFLAGS or related variables.

            regards, tom lane

Re: BUG #1999: contrib/spi doesn't receive the configured

From
Seneca Cunningham
Date:
Tom Lane wrote:
> "Seneca Cunningham" <scunning@ca.afilias.info> writes:
>
>>$ cd postgresql-8.1beta4
>>$ export OBJECT_MODE=64
>>$ CFLAGS="-maix64 -Wl,-bbigtoc" ./configure
>>--prefix=/opt/dbs/pgsql81b4-afilias-AIX53-2005-10-25
>>--with-includes=/opt/freeware/include --enable-debug --enable-thread-safety
>>--with-libraries=/opt/freeware/lib --enable-casert
>
>
> This is your error.  -Wl,-bbigtoc is not a compiler flag, it's a linker
> flag, and hence should be specified in LDFLAGS or related variables.

I redid the build changing CFLAGS to "-maix64" and LDFLAGS to
"-Wl,-bbigtoc", and gmake check still doesn't run without first
modifying src/makefiles/Makefile.aix to add CFLAGS.  The -maix64 from
CFLAGS is required to get contrib/spi to build since IBM's tools are
expecting objects using the 64-bit API to operate on, and if I were to
unset OBJECT_MODE, the linking would fail as ld cannot link against
XCOFF64 files in 32-bit mode.

--
Seneca Cunningham
scunning@ca.afilias.info

Re: BUG #1999: contrib/spi doesn't receive the configured CFLAGS

From
Tom Lane
Date:
Seneca Cunningham <scunning@ca.afilias.info> writes:
> I redid the build changing CFLAGS to "-maix64" and LDFLAGS to
> "-Wl,-bbigtoc", and gmake check still doesn't run without first
> modifying src/makefiles/Makefile.aix to add CFLAGS.  The -maix64 from
> CFLAGS is required to get contrib/spi to build since IBM's tools are
> expecting objects using the 64-bit API to operate on, and if I were to
> unset OBJECT_MODE, the linking would fail as ld cannot link against
> XCOFF64 files in 32-bit mode.

Hmm.  I think the command in Makefile.aix is correct, since it's only
doing a link and not a compilation.

    $(CC) $(LDFLAGS) $(LDFLAGS_SL) -o $@ $*.o -Wl,-bI:$(top_builddir)/src/backend/$(POSTGRES_IMP) -Wl,-bE:$*$(EXPSUFF)
$(SHLIB_LINK)

Given that you want -maix64 to be supplied in both compilation and
linking phases, you could either add it to both FLAGS variables, or
put it in CC:

    CC="gcc -maix64" ...

I've done stuff like the latter fairly often when fooling with 32/64 bit
build environments.

            regards, tom lane