From aixtools at gmail.com  Thu Oct 15 14:32:16 2015
From: aixtools at gmail.com (Michael Felt)
Date: Thu, 15 Oct 2015 14:32:16 +0200
Subject: [Rd] Building R for AIX in 64-bit mode
Message-ID: <CANvxniVBrCaT1C3HosULfg4OfBNkL-vQqnFuTt+j=pfMbovX_Q@mail.gmail.com>

Hi.

Just wanted to let you know I am getting close to packaging R for AIX in
64.bit mode.

One comment - the libtool.m4 I see used is quite old. The one I have on my
system is 2.4.6, and what I see in R says:

I am hoping a new libtool will clean up most of the manual work now needed.

# Which release of libtool.m4 was used?
macro_version=2.2.6
macro_revision=1.3012

This may be all that is needed to cleanup what I am doing manually.

working with gcc I have done the following for 64-bit building

export OBJECT_MODE=64
export CFLAGS="-maix64 -O2"
export FFLAGS="-maix64 -O2"
export LDFLAGS="-lpthread"

Note - it does not look as if LDFLAGS is actually being picked up, but
maybe I had a typo.

The first error I get is:

Target "libunix.a" is up to date.
        gcc -std=gnu99 -I. -I../../src/include -I../../src/include
-I/opt/buildaix/include -I/opt/include -DHAVE_CONFIG_H  -mminimal-toc
-I/opt/include -I/opt/buildaix/include -maix64 -O2  -L/usr/local/lib
-DR_HOME='"/data/prj/cran/64/R-3.2.2"'  -o Rscript ./Rscript.c
        gcc -std=gnu99 -Wl,-brtl -Wl,-bexpall -Wl,-bpT:0x100000000
-Wl,-bpD:0x110000000 -lc   -Wl,-bE:../../etc/R.exp  -L/usr/local/lib -o
R.bin Rmain.o CommandLineArgs.o Rdynload.o Renviron.o RNG.o agrep.o apply.o
arithmetic.o array.o attrib.o bind.o builtin.o character.o coerce.o
colors.o complex.o connections.o context.o cum.o dcf.o datetime.o debug.o
deparse.o devices.o dotcode.o dounzip.o dstruct.o duplicate.o edit.o
engine.o envir.o errors.o eval.o format.o gevents.o gram.o gram-ex.o
graphics.o grep.o identical.o inlined.o inspect.o internet.o iosupport.o
lapack.o list.o localecharset.o logic.o main.o mapply.o match.o memory.o
names.o objects.o options.o paste.o platform.o plot.o plot3d.o plotmath.o
print.o printarray.o printvector.o printutils.o qsort.o random.o raw.o
registration.o relop.o rlocale.o saveload.o scan.o seq.o serialize.o sort.o
source.o split.o sprintf.o startup.o subassign.o subscript.o subset.o
summary.o sysutils.o times.o unique.o util.o version.o g_alab_her.o
g_cntrlify.o g_fontdb.o g_her_glyph.o xxxpr.o   `ls ../unix/*.o ../appl/*.o
../nmath/*.o`  ../extra/bzip2/libbz2.a ../extra/pcre/libpcre.a
../extra/tre/libtre.a  ../extra/xz/liblzma.a ../extra/intl/libintl.a
-lgfortran -lm /opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/ppc64/libgcc.a
-lz -lrt -ldl -lm -liconv
ld: 0711-738 ERROR: Input file /lib/crt0.o:
        XCOFF32 object files are not allowed in 64-bit mode.

This is repaired by adding the -maix64 flag again to the gcc comand used to
link.

The following steps - first cut/paste the original command, then add -maix64

root at x072:[/data/prj/cran/64/R-3.2.2]cd src/main
root at x072:[/data/prj/cran/64/R-3.2.2/src/main]ran -lm
/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/ppc64/libgcc.a     -lz -lrt -ldl
-lm -liconv               <
ld: 0711-738 ERROR: Input file /lib/crt0.o:
        XCOFF32 object files are not allowed in 64-bit mode.
collect2: error: ld returned 8 exit status
root at x072:[/data/prj/cran/64/R-3.2.2/src/main] gcc -maix64 -std=gnu99
-Wl,-brtl -Wl,-bexpall -Wl,-bpT:0x100000000 -Wl,-bpD:0x110000000 -lc
-Wl,-bE:../../>
ld: 0711-415 WARNING: Symbol BM_norm_keep is already exported.
ld: 0711-415 WARNING: Symbol LoadInitFile is already exported.
ld: 0711-415 WARNING: Symbol N01_kind is already exported.
ld: 0711-415 WARNING: Symbol R_ReadItemDepth is already exported.
ld: 0711-224 WARNING: Duplicate symbol: BM_norm_keep
ld: 0711-224 WARNING: Duplicate symbol: N01_kind
ld: 0711-224 WARNING: Duplicate symbol: LoadInitFile
ld: 0711-224 WARNING: Duplicate symbol: R_ReadItemDepth
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
information.
ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_lock
ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_unlock
collect2: error: ld returned 8 exit status
root at x072:[/data/prj/cran/64/R-3.2.2/src/main]

Now add the -lpthread

gcc -maix64 -std=gnu99 -Wl,-brtl -Wl,-bexpall -Wl,-bpT:0x100000000
-Wl,-bpD:0x110000000 -lc   -Wl,-bE:../../etc/R.exp  -L/usr/local/lib -o
R.bin Rmain.o Comma
ndLineArgs.o Rdynload.o Renviron.o RNG.o agrep.o apply.o arithmetic.o
array.o attrib.o bind.o builtin.o character.o coerce.o colors.o complex.o
connections.o
context.o cum.o dcf.o datetime.o debug.o deparse.o devices.o dotcode.o
dounzip.o dstruct.o duplicate.o edit.o engine.o envir.o errors.o eval.o
format.o gevent
s.o gram.o gram-ex.o graphics.o grep.o identical.o inlined.o inspect.o
internet.o iosupport.o lapack.o list.o localecharset.o logic.o main.o
mapply.o match.o
memory.o names.o objects.o options.o paste.o platform.o plot.o plot3d.o
plotmath.o print.o printarray.o printvector.o printutils.o qsort.o random.o
raw.o regi
stration.o relop.o rlocale.o saveload.o scan.o seq.o serialize.o sort.o
source.o split.o sprintf.o startup.o subassign.o subscript.o subset.o
summary.o sysuti
ls.o times.o unique.o util.o version.o g_alab_her.o g_cntrlify.o g_fontdb.o
g_her_glyph.o xxxpr.o   `ls ../unix/*.o ../appl/*.o ../nmath/*.o`
../extra/bzip2/
libbz2.a ../extra/pcre/libpcre.a ../extra/tre/libtre.a
../extra/xz/liblzma.a ../extra/intl/libintl.a   -lgfortran -lm
/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7
.4/ppc64/libgcc.a     -lz -lrt -ldl -lm -liconv -lpthread

gcc -maix64 -std=gnu99 -Wl,-brtl -Wl,-bexpall -Wl,-bpT:0x100000000
-Wl,-bpD:0x110000000 -lc   -Wl,-bE:../../etc/R.exp  -L/usr/local/lib -o
R.bin Rmain.o CommandLineArgs.o Rdynload.o Renviron.o RNG.o agrep.o apply.o
arithmetic.o array.o attrib.o bind.o builtin.o character.o coerce.o
colors.o complex.o connections.o context.o cum.o dcf.o datetime.o debug.o
deparse.o devices.o dotcode.o dounzip.o dstruct.o duplicate.o edit.o
engine.o envir.o errors.o eval.o format.o gevents.o gram.o gram-ex.o
graphics.o grep.o identical.o inlined.o inspect.o internet.o iosupport.o
lapack.o list.o localecharset.o logic.o main.o mapply.o match.o memory.o
names.o objects.o options.o paste.o platform.o plot.o plot3d.o plotmath.o
print.o printarray.o printvector.o printutils.o qsort.o random.o raw.o
registration.o relop.o rlocale.o saveload.o scan.o seq.o serialize.o sort.o
source.o split.o sprintf.o startup.o subassign.o subscript.o subset.o
summary.o sysutils.o times.o unique.o util.o version.o g_alab_her.o
g_cntrlify.o g_fontdb.o g_her_glyph.o xxxpr.o   `ls ../unix/*.o ../appl/*.o
../nmath/*.o`  ../extra/bzip2/libbz2.a ../extra/pcre/libpcre.a
../extra/tre/libtre.a  ../extra/xz/liblzma.a ../extra/intl/libintl.a
-lgfortran -lm /opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/ppc64/libgcc.a
-lz -lrt -ldl -lm -liconv -lpthread
ld: 0711-415 WARNING: Symbol BM_norm_keep is already exported.
ld: 0711-415 WARNING: Symbol LoadInitFile is already exported.
ld: 0711-415 WARNING: Symbol N01_kind is already exported.
ld: 0711-415 WARNING: Symbol R_ReadItemDepth is already exported.
ld: 0711-224 WARNING: Duplicate symbol: BM_norm_keep
ld: 0711-224 WARNING: Duplicate symbol: N01_kind
ld: 0711-224 WARNING: Duplicate symbol: LoadInitFile
ld: 0711-224 WARNING: Duplicate symbol: R_ReadItemDepth
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
information.

Note: this is with 3.2.2 - with 3.1.3 I did not get the Duplicate symbols.


(Using the same command in the 3.1.3 directory shows there are some other
differences)

root at x072:[/data/prj/cran/64/R-3.1.3/src/main]gcc -maix64 -std=gnu99
-Wl,-brtl -Wl,-bexpall -Wl,-bpT:0x100000000 -Wl,-bpD:0>
gcc: error: g_alab_her.o: A file or directory in the path name does not
exist.
gcc: error: g_cntrlify.o: A file or directory in the path name does not
exist.
gcc: error: g_fontdb.o: A file or directory in the path name does not exist.
gcc: error: g_her_glyph.o: A file or directory in the path name does not
exist.

so, since I am getting farther with 3.1.3 - I shall continue this
INFORMATIONAL post.

root at x072:[/data/prj/cran/64/R-3.1.3/src/main]rm R.bin

root at x072:[/data/prj/cran/64/R-3.1.3/src/main]gcc -std=gnu99 -Wl,-brtl
-Wl,-bexpall -Wl,-bpT:0x100000000 -Wl,-bpD:0x110000000 -lc
-Wl,-bE:../../etc/R.exp  -L/usr/l>
ld: 0706-020 The number 0x100000000 is too large for the -b pT option.
        Use a value that is 4294967295 (hex FFFFFFFF) or less.
ld: 0706-020 The number 0x110000000 is too large for the -b pD option.
        Use a value that is 4294967295 (hex FFFFFFFF) or less.
collect2: error: ld returned 255 exit status
root at x072:[/data/prj/cran/64/R-3.1.3/src/main]gcc -maix64 -std=gnu99
-Wl,-brtl -Wl,-bexpall -Wl,-bpT:0x100000000 -Wl,-bpD:0x110000000 -lc
-Wl,-bE:../../etc/R.exp  >
ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_lock
ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_unlock
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
information.
collect2: error: ld returned 8 exit status
root at x072:[/data/prj/cran/64/R-3.1.3/src/main]bm-aix5.3.0.0/4.7.4/ppc64/libgcc.a
-lrt -ldl -lm -liconv -lpthread

This is a kind of error that occurs frequently - the argument -shared
causes "issues"

Target "libRlapack.so" is up to date.
/data/prj/cran/64/R-3.1.3/lib/libRlapack.so is unchanged
        gcc -std=gnu99 -shared -Wl,-brtl -Wl,-G -Wl,-bexpall -Wl,-bnoentry
-lc  -L/usr/local/lib -o lapack.so  Lapack.o     -L../../../lib -lRlapack
-lgfortran -lm /opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/ppc64/libgcc.a
ld: 0711-736 ERROR: Input file Lapack.o:
        XCOFF64 object files are not allowed in 32-bit mode.
collect2: error: ld returned 8 exit status
make: 1254-004 The error code from the last command is 1.

changing -shared for -maix64 has "fixed" it up to now - Now however, back
to duplicate symbols:

gcc: error: Lapack.o: A file or directory in the path name does not exist.
root at x072:[/data/prj/cran/64/R-3.1.3/src/modules]cd lapack
root at x072:[/data/prj/cran/64/R-3.1.3/src/modules/lapack] gcc -std=gnu99
-shared -Wl,-brtl -Wl,-G -Wl,-bexpall -Wl,-bnoentry -lc  -L/usr/local/lib
-o lapack.so  Lapac>
ld: 0711-736 ERROR: Input file Lapack.o:
        XCOFF64 object files are not allowed in 32-bit mode.
collect2: error: ld returned 8 exit status
root at x072:[/data/prj/cran/64/R-3.1.3/src/modules/lapack]gcc -std=gnu99
-maix64  -Wl,-brtl -Wl,-G -Wl,-bexpall -Wl,-bnoentry -lc  -L/usr/local/lib
-o lapack.so  Lapac>
ld: 0711-224 WARNING: Duplicate symbol: p_xargc
ld: 0711-224 WARNING: Duplicate symbol: p_xargv
ld: 0711-224 WARNING: Duplicate symbol: p_xrcfg
ld: 0711-224 WARNING: Duplicate symbol: p_xrc
ld: 0711-224 WARNING: Duplicate symbol: end
ld: 0711-224 WARNING: Duplicate symbol: .memcpy
ld: 0711-224 WARNING: Duplicate symbol: memcpy
ld: 0711-224 WARNING: Duplicate symbol: .bcopy
ld: 0711-224 WARNING: Duplicate symbol: bcopy
ld: 0711-224 WARNING: Duplicate symbol: .strcmp
ld: 0711-224 WARNING: Duplicate symbol: strcmp
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
information.
root at x072:[/data/prj/cran/64/R-3.1.3/src/modules/lapack]

So, for today, my story ends with
gcc -Wl,-bloadmap:aixtools -std=gnu99 -maix64  -Wl,-brtl -Wl,-G
-Wl,-bexpall -Wl,-bnoentry -lc  -L/usr/local/lib -o lapack.so  Lapack.o
-L../../../lib -lRlapack  -lgfortran -lm
/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/ppc64/libgcc.a

ld: 0711-228 WARNING: Duplicate symbols were found while resolving symbols.
        The following duplicates were found:
 Symbol                    Source-File(Object) OR Import-File{Shared-object}
 ------------------------- -------------------------------------------------
 p_xargc                   crt0_64.s(/lib/crt0_64.o)
    ** Duplicate **        {../../../lib/libRlapack.so}
 p_xargv                   crt0_64.s(/lib/crt0_64.o)
    ** Duplicate **        {../../../lib/libRlapack.so}
 p_xrcfg                   crt0_64.s(/lib/crt0_64.o)
    ** Duplicate **        {../../../lib/libRlapack.so}
 p_xrc                     crt0_64.s(/lib/crt0_64.o)
    ** Duplicate **        {../../../lib/libRlapack.so}
 end                       crt0_64.s(/lib/crt0_64.o)
    ** Duplicate **        {../../../lib/libRlapack.so}
 .memcpy                   moveeq.s(/usr/lib/libc.a[moveeq_64.o])
    ** Duplicate **        {../../../lib/libRlapack.so}
 memcpy                    moveeq.s(/usr/lib/libc.a[moveeq_64.o])
    ** Duplicate **        {../../../lib/libRlapack.so}
 .bcopy                    moveeq.s(/usr/lib/libc.a[moveeq_64.o])
    ** Duplicate **        {../../../lib/libRlapack.so}
 bcopy                     moveeq.s(/usr/lib/libc.a[moveeq_64.o])
    ** Duplicate **        {../../../lib/libRlapack.so}
 .strcmp                   strcmp.s(/usr/lib/libc.a[strcmp_64.o])
    ** Duplicate **        {../../../lib/libRlapack.so}
 strcmp                    strcmp.s(/usr/lib/libc.a[strcmp_64.o])
    ** Duplicate **        {../../../lib/libRlapack.so}

	[[alternative HTML version deleted]]



[Rd] Building R for AIX in 64-bit mode
Michael Felt