Opened 16 years ago

Closed 16 years ago

#1927 closed defect (fixed)

GDAL build for Solaris sparcv9 fails after libraries successfully built

Reported by: castalia Owned by: Mateusz Łoskot
Priority: normal Milestone: 1.5.1
Component: ConfigBuild Version: 1.4.2
Severity: normal Keywords: Solaris sparcv9 build
Cc:

Description

Host build system: SunOS deimos 5.9 Generic_118558-17 sun4u sparc SUNW,Sun-Fire-V210 Solaris

After setting the CFALGS, CXXFLAGS and LDFLAGS environment variables to "-mcpu=v9 -m64" and running ./configure and starting the build with the default make target, the build proceeds successfully through the compiliation of object modules and the creation of libraries, both static and dynamic. However, at the point where ogrinfo is to be built an error occurs due to an ELF class conflict:

gmake[1]: Entering directory `/apps/opt/pub/src/gdal-1.4.2/ogr' /bin/sh /opt/pub/src/gdal-1.4.2/libtool --mode=link g++ ogrinfo.o /opt/pub/src/gdal-1.4.2/libgdal.la -o ogrinfo g++ ogrinfo.o -o .libs/ogrinfo /opt/pub/src/gdal-1.4.2/.libs/libgdal.so -lz -lrt -ldl -L/opt/pub/lib -Wl,-R -Wl,/home/pirl/castalia/tmp/gdal/sparcv9/lib ld: fatal: file ogrinfo.o: wrong ELF class: ELFCLASS64 ld: fatal: File processing errors. No output written to .libs/ogrinfo collect2: ld returned 1 exit status gmake[1]: * [ogrinfo] Error 1 gmake[1]: Leaving directory `/apps/opt/pub/src/gdal-1.4.2/ogr' gmake: * [ogr-apps] Error 2

Note the lack of the required -mcpu=v9 -m64 switches on the g++ command line. Manually entering the ogr directory and submitting the g++ command line with the required switches works correctly. So the problem is an inconsistency in the GDAL build system.

Bradford Castalia Senior Systems Analyst Planetary Image Research Laboratory / HiRISE Operations Center University of Arizona

Change History (8)

comment:1 by Mateusz Łoskot, 16 years ago

Status: newassigned

Bradford,

I don't have access to SunOS on Sparc but only Solaris Express Dev. Edition what's not very helpful here. Anyway, I will try to give some suggestion.

First, you don't need to add -mcpu and -m64 flags to all *FLAGS manually. You can just use USER_DEFS and GDAL makefiles will append it automatically where required:

  • for .c files compiled as C programs (like gdalinfo.c, gdaltindex.c) to CFLAGS
  • for .cpp files compiled as C++ programs (like ogrinfo.cpp, ogr2ogr.cpp), to CXXFLAGS

Note, these options are not needed to be added to CPPFLAGS.

Could you try to pass your flags as follows and let me know if it works?

make 'USER_DEFS='"-mcpu=v9 -m64"

then you should see these flag appended automatically, like this:

gcc -Wall -Wdeclaration-after-statement -fPIC -O2  -mcpu=v9 -m64
...

comment:2 by Mateusz Łoskot, 16 years ago

Bradford,

I'd like to give a few additional notes. I'm not sure what's the version of GCC and binutils on your SunOS but there have been some changes in GCC regarding flags like -march and -mcpu. These two flags are considered as old style and are not supported in new versions of GCC+binutils (you may get errors like error: invalid option cpu):

  • GCC 3.2.x and binutils 2.13 support old style flags
  • GCC 3.3.x and binutils 2.14 (and later versions) support new flags

The new flag I'm referring here is -mtune and if you have newer GCC you probably will need to use -mtune=v9. For details, I'd suggest to run man gcc and check -march, -mcpu and -mtune flags info. In example, manual for GCC 4.0.x says:

    -mcpu=cpu-type
           A deprecated synonym for -mtune.

BTW, there is another way to specify these flags, next to use USER_DEFS:

export CFLAGS="-mcpu=v9 -m64"
export CXXFLAGS=$CFLAGS
./configure
make
...

In this version, you should see your flags used in the ./configure summary.

comment:3 by Mateusz Łoskot, 16 years ago

Here is more information about changes related to -mcpu/-mtune flags:

[http://gcc.gnu.org/gcc-3.3/changes.html GCC 3.3 Release Series Changes, New Features, and Fixes]

comment:4 by Mateusz Łoskot, 16 years ago

During more detailed investigation we've identified there are some issues like ignored CXXFLAGS and CFLAGS in GDALmake.opt.in file for debug building, etc. So, new reports was created dedicated to discussion about similar issues:

1929 - Missing compilation and linking flags on Unix

comment:5 by Mateusz Łoskot, 16 years ago

Milestone: 1.4.31.5.0

According to the #1929, the problem is with not properly used LDFLAGS. However, it's too risky to fix it in stable branch 1.4, so I'm moving this ticket to 1.5.0 and then we will apply fixes only in trunk.

comment:6 by Mateusz Łoskot, 16 years ago

Component: BuildbotConfigBuild

comment:7 by Mateusz Łoskot, 16 years ago

Fixed setting user's CFLAGS and CXXFLAGS (r13129)

comment:8 by Mateusz Łoskot, 16 years ago

Resolution: fixed
Status: assignedclosed

Hopefully, this issue has been fixed by patches applied to this ticket (see changeset numbers in comments above) as well as patches applied for #1929.

Note: See TracTickets for help on using tickets.