From aixtools at gmail.com  Sat Oct 24 19:46:24 2015
From: aixtools at gmail.com (Michael Felt)
Date: Sat, 24 Oct 2015 19:46:24 +0200
Subject: [Rd] Building R for AIX in 32-bit mode - as preparation for
 building in 64-bit mode (changed subject!) - INFO/FEEDBACK - do not read as
 a bug report!
In-Reply-To: <5623EDCA.5030309@gmail.com>
References: <CANvxniVBrCaT1C3HosULfg4OfBNkL-vQqnFuTt+j=pfMbovX_Q@mail.gmail.com>
	<561FA401.7010207@stats.ox.ac.uk> <5623EDCA.5030309@gmail.com>
Message-ID: <CANvxniVXGruV+up17C4gy48V23aoPjQk=CM0M_QyxUa7vaJQHw@mail.gmail.com>

I have determined why there are many "WARNING: Duplicate symbol:" messages.

*** My apologies for the length *** There is a lot of detail - but I
hope the detail will help R - and others - setup correct options for
shared libraries.
*** As I press send, I have not stopped testing (my final trial here
might not even work) - but!
*** the message is that shared libraries do not need to have all
external libraries on the command line to make a shareable library
(that is the whole point of multiple shared libraries I think)

Anyway, I hope you are"in" for a long read.

a) the duplicate symbol messages occur during the creation (read
linking) of a shared object.
b) the shared object does not need to have all symbols resolved -
actually, you do not want "external" symbols from elsewhere pulled
into to the archive.
c) one example - stats.so

currently the command to make stats.so is:

gcc -Wl,-bnoquiet -std=gnu99 -shared -Wl,-brtl -Wl,-G -Wl,-bexpall
-Wl,-bnoentry  -o stats.so init.o kmeans.o ansari.o bandwidth
s.o chisqsim.o d2x2xk.o fexact.o kendall.o ks.o line.o smooth.o prho.o
swilk.o ksmooth.o loessc.o monoSpl.o isoreg.o Srunmed.o d
blcen.o distance.o hclust-utils.o nls.o rWishart.o HoltWinters.o
PPsum.o arima.o burg.o filter.o mAR.o pacf.o starma.o port.o fa
mily.o sbart.o approx.o loglin.o lowess.o massdist.o splines.o lm.o
complete_cases.o cov.o deriv.o fft.o fourier.o model.o optim
.o optimize.o integrate.o random.o distn.o zeroin.o rcont.o
influence.o bsplvd.o bvalue.o bvalus.o loessf.o ppr.o qsbart.o sgram
.o sinerp.o sslvrg.o stxwx.o hclust.o kmns.o eureka.o stl.o portsrc.o
lminfl.o -fopenmp -L../../../../lib -lRlapack -lgfortran -
lm /opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/libgcc.a -lg -lm
/opt/lib/libintl.a /opt/lib/libiconv.a -lpthread

The result has duplicate symbols:

With comments:

gcc -Wl,-bnoquiet -std=gnu99 -shared -Wl,-brtl -Wl,-G -Wl,-bexpall
-Wl,-bnoentry  -o stats.so init.o kmeans.o ansari.o bandwidths.o
chisqsim.o d2x2xk.o fexact.o kendall.o ks.o line.o smooth.o prho.o
swilk.o ksmooth.o loessc.o monoSpl.o isoreg.o Srunmed.o dblcen.o
distance.o hclust-utils.o nls.o rWishart.o HoltWinters.o PPsum.o
arima.o burg.o filter.o mAR.o pacf.o starma.o port.o family.o sbart.o
approx.o loglin.o lowess.o massdist.o splines.o lm.o complete_cases.o
cov.o deriv.o fft.o fourier.o model.o optim.o optimize.o integrate.o
random.o distn.o zeroin.o rcont.o influence.o bsplvd.o bvalue.o
bvalus.o loessf.o ppr.o qsbart.o sgram.o sinerp.o sslvrg.o stxwx.o
hclust.o kmns.o eureka.o stl.o portsrc.o lminfl.o -fopenmp
-L../../../../lib -lRlapack -lgfortran -lm
/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/libgcc.a -lg -lm
/opt/lib/libintl.a /opt/lib/libiconv.a -lpthread -lc
(ld): halt 4
** Display the options passed to ld
(ld): setopt r/o->w
(ld): setopt nodelcsect
(ld): setopt noautoexp
(ld): setopt expall
(ld): setopt rtl
(ld): setopt nortllib
(ld): setopt symbolic:0
(ld): setfflag 4
(ld): savename stats.so
(ld): filelist 82 2
** not a program, not all symbols need to resolve
(ld): setopt noprogram
** not a program, not a defined entry point
(ld): noentry
NOENTRY: There is no entry point.
** link/load these objects
(ld): i init.o
(ld): i /tmp//ccc85WAT.o
(ld): i kmeans.o
(ld): i ansari.o
(ld): i bandwidths.o
(ld): i chisqsim.o
(ld): i d2x2xk.o
(ld): i fexact.o
(ld): i kendall.o
(ld): i ks.o
(ld): i line.o
(ld): i smooth.o
(ld): i prho.o
(ld): i swilk.o
(ld): i ksmooth.o
(ld): i loessc.o
(ld): i monoSpl.o
(ld): i isoreg.o
(ld): i Srunmed.o
(ld): i dblcen.o
(ld): i distance.o
(ld): i hclust-utils.o
(ld): i nls.o
(ld): i rWishart.o
(ld): i HoltWinters.o
(ld): i PPsum.o
(ld): i arima.o
(ld): i burg.o
(ld): i filter.o
(ld): i mAR.o
(ld): i pacf.o
(ld): i starma.o
(ld): i port.o
(ld): i family.o
(ld): i sbart.o
(ld): i approx.o
(ld): i loglin.o
(ld): i lowess.o
(ld): i massdist.o
(ld): i splines.o
(ld): i lm.o
(ld): i complete_cases.o
(ld): i cov.o
(ld): i deriv.o
(ld): i fft.o
(ld): i fourier.o
(ld): i model.o
(ld): i optim.o
(ld): i optimize.o
(ld): i integrate.o
(ld): i random.o
(ld): i distn.o
(ld): i zeroin.o
(ld): i rcont.o
(ld): i influence.o
(ld): i bsplvd.o
(ld): i bvalue.o
(ld): i bvalus.o
(ld): i loessf.o
(ld): i ppr.o
(ld): i qsbart.o
(ld): i sgram.o
(ld): i sinerp.o
(ld): i sslvrg.o
(ld): i stxwx.o
(ld): i hclust.o
(ld): i kmns.o
(ld): i eureka.o
(ld): i stl.o
(ld): i portsrc.o
(ld): i lminfl.o
** continue loading objects - these are archives!
(ld): lib ../../../../lib/libRlapack.so
(ld): lib /opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/../../../pthread/libgfortran.a
(ld): lib /usr/lib/libm.a
(ld): i /opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/libgcc.a
(ld): lib /usr/lib/libg.a
(ld): i /opt/lib/libintl.a
(ld): i /opt/lib/libiconv.a
(ld): lib /usr/lib/libpthread.a
(ld): lib /usr/lib/libc.a
(ld): lib /opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/../../../pthread/libgomp.a
(ld): lib /opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/../../../pthread/libgcc_s.a
** Import Symbols from the shared objects
LIBRARY: Shared object libRlapack.so: 574 symbols imported.
LIBRARY: Shared object libgfortran.a[libgfortran.so.3]: 1014 symbols imported.
LIBRARY: Shared object /opt/lib/libintl.a[libintl.so.8]: 58 symbols imported.
LIBRARY: Shared object /opt/lib/libiconv.a[libiconv.so.2]: 13 symbols imported.
LIBRARY: Shared object /opt/lib/libiconv.a[shr4.o]: 10 symbols imported.
LIBRARY: Shared object /opt/lib/libiconv.a[shr.o]: 11 symbols imported.
LIBRARY: Shared object libpthread.a[shr_comm.o]: 179 symbols imported.
LIBRARY: Shared object libpthread.a[shr_xpg5.o]: 173 symbols imported.
LIBRARY: Shared object libc.a[shr.o]: 3287 symbols imported.
LIBRARY: Shared object libc.a[meth.o]: 2 symbols imported.
LIBRARY: Shared object libc.a[posix_aio.o]: 20 symbols imported.
LIBRARY: Shared object libc.a[aio.o]: 18 symbols imported.
LIBRARY: Shared object libc.a[pse.o]: 8 symbols imported.
LIBRARY: Shared object libc.a[dl.o]: 4 symbols imported.
LIBRARY: Shared object libc.a[pty.o]: 1 symbols imported.
LIBRARY: Shared object libc.a[cthread.o]: 25 symbols imported.
LIBRARY: Shared object libc.a[uchar.o]: 4 symbols imported.
LIBRARY: Shared object libgomp.a[libgomp.so.1]: 228 symbols imported.
LIBRARY: Shared object libgcc_s.a[shr.o]: 127 symbols imported.
FILELIST: Number of previously inserted files processed: 82
** load the symbols we are exporting
(ld): exports /tmp//ccNjuEdL.x
EXPORTS: Symbols exported: 312
(ld): initfini _GLOBAL__FI_stats_so _GLOBAL__FD_stats_so
(ld): resolve
** during symbol resolution we see duplicates!!!
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}
 ------------------------- -------------------------------------------------
 .fsav                     {../../../../lib/libRlapack.so}
    ** Duplicate **        noname(/usr/lib/libc.a[fsavres.o])
 .fres                     {../../../../lib/libRlapack.so}
    ** Duplicate **        noname(/usr/lib/libc.a[fsavres.o])
 .memcpy                   {../../../../lib/libRlapack.so}
    ** Duplicate **        moveeq.s(/usr/lib/libc.a[moveeq.o])
 .isnan                    {../../../../lib/libRlapack.so}
    ** Duplicate **        isnan.s(/usr/lib/libm.a[isnan.o])
 .finite                   {../../../../lib/libRlapack.so}
    ** Duplicate **        finite.s(/usr/lib/libm.a[finite.o])
    ** Duplicate **        finite.s(/usr/lib/libc.a[finite.o])
 .bcopy                    {../../../../lib/libRlapack.so}
    ** Duplicate **        moveeq.s(/usr/lib/libc.a[moveeq.o])
RESOLVE: 1395 of 10573 symbols were kept.
RESOLVE: The return code is 4.
** sigh - do not know what glink.o is...
(ld): addgl /usr/lib/glink.o
ADDGL: Glink code added for 507 symbols.
(ld): mismatch
MISMATCH: No type mismatches exist.
(ld): comprld
COMPRLD: Kept 10436 of 10436 relocation entries.
(ld): origin page 0x10000000 0x20000000
(ld): libpath ../../../../lib:/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/pthread:/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/../../../pthread:/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4:/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/../../..:/usr/lib:/lib
LIBPATH: Library path set to
../../../../lib:/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/pthread:/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/../../../pthread:/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4:/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/../../..:/usr/lib:/lib
(ld): save SRE .
SAVE: Section sizes = 582204+13364+884 (0x8E23C+0x3434+0x374 hex)
SAVE: Size of TOC: 4048 (0xFD0 hex)
SAVE: No .loader section relocation entries exist for the .text section.
(ld): rc
RC: Highest return code was 4.
ld: 0711-224 WARNING: Duplicate symbol: .fsav
ld: 0711-224 WARNING: Duplicate symbol: .fres
ld: 0711-224 WARNING: Duplicate symbol: .memcpy
ld: 0711-224 WARNING: Duplicate symbol: .isnan
ld: 0711-224 WARNING: Duplicate symbol: .finite
ld: 0711-224 WARNING: Duplicate symbol: .bcopy

OKAY - lets first just get rid of the Duplicates - by removing some
references to external (shared) libraries.

Now after removing the arguments -lRlapack and -lc the command looks like:

gcc -Wl,-bnoquiet -std=gnu99 -shared -Wl,-brtl -Wl,-G -Wl,-bexpall
-Wl,-bnoentry  -o stats.so init.o kmeans.o ansari.o bandwidth
s.o chisqsim.o d2x2xk.o fexact.o kendall.o ks.o line.o smooth.o prho.o
swilk.o ksmooth.o loessc.o monoSpl.o isoreg.o Srunmed.o d
blcen.o distance.o hclust-utils.o nls.o rWishart.o HoltWinters.o
PPsum.o arima.o burg.o filter.o mAR.o pacf.o starma.o port.o fa
mily.o sbart.o approx.o loglin.o lowess.o massdist.o splines.o lm.o
complete_cases.o cov.o deriv.o fft.o fourier.o model.o optim
.o optimize.o integrate.o random.o distn.o zeroin.o rcont.o
influence.o bsplvd.o bvalue.o bvalus.o loessf.o ppr.o qsbart.o sgram
.o sinerp.o sslvrg.o stxwx.o hclust.o kmns.o eureka.o stl.o portsrc.o
lminfl.o -fopenmp -L../../../../lib -lgfortran -lm /opt/li
b/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/libgcc.a -lg -lm /opt/lib/libintl.a
/opt/lib/libiconv.a -lpthread

And the result is (truncated)

FILELIST: Number of previously inserted files processed: 81
(ld): exports /tmp//ccSxDrfr.x
EXPORTS: Symbols exported: 312
(ld): initfini _GLOBAL__FI_stats_so _GLOBAL__FD_stats_so
(ld): resolve
RESOLVE: 1638 of 10364 symbols were kept.
(ld): addgl /usr/lib/glink.o
ADDGL: Glink code added for 538 symbols.
(ld): mismatch
MISMATCH: No type mismatches exist.
(ld): comprld
COMPRLD: Kept 11305 of 11305 relocation entries.
(ld): origin page 0x10000000 0x20000000
(ld): libpath ../../../../lib:/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/pthread:/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/../../../pthread:/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4:/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/../../..:/usr/lib:/lib
LIBPATH: Library path set to
../../../../lib:/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/pthread:/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/../../../pthread:/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4:/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/../../..:/usr/lib:/lib
(ld): save SRE .
SAVE: Section sizes = 624252+44524+1128 (0x9867C+0xADEC+0x468 hex)
SAVE: Size of TOC: 4452 (0x1164 hex)
SAVE: No .loader section relocation entries exist for the .text section.
(ld): rc
RC: Highest return code was 0.

Note: RC is 0, rather than 4 (warnings)

Now, lets try removing ALL the external libraries (better, all
arguments from -fopenmp to the end of command)

gcc -Wl,-bnoquiet -std=gnu99 -shared -Wl,-brtl -Wl,-G -Wl,-bexpall
-Wl,-bnoentry  -o stats.so init.o kmeans.o ansari.o bandwidth
s.o chisqsim.o d2x2xk.o fexact.o kendall.o ks.o line.o smooth.o prho.o
swilk.o ksmooth.o loessc.o monoSpl.o isoreg.o Srunmed.o d
blcen.o distance.o hclust-utils.o nls.o rWishart.o HoltWinters.o
PPsum.o arima.o burg.o filter.o mAR.o pacf.o starma.o port.o fa
mily.o sbart.o approx.o loglin.o lowess.o massdist.o splines.o lm.o
complete_cases.o cov.o deriv.o fft.o fourier.o model.o optim
.o optimize.o integrate.o random.o distn.o zeroin.o rcont.o
influence.o bsplvd.o bvalue.o bvalus.o loessf.o ppr.o qsbart.o sgram
.o sinerp.o sslvrg.o stxwx.o hclust.o kmns.o eureka.o stl.o portsrc.o lminfl.o

(ld): lib /opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/../../../libgcc_s.a
(ld): lib /usr/lib/libc.a
LIBRARY: Shared object libgcc_s.a[shr.o]: 127 symbols imported.
LIBRARY: Shared object libc.a[shr.o]: 3287 symbols imported.
LIBRARY: Shared object libc.a[meth.o]: 2 symbols imported.
LIBRARY: Shared object libc.a[posix_aio.o]: 20 symbols imported.
LIBRARY: Shared object libc.a[aio.o]: 18 symbols imported.
LIBRARY: Shared object libc.a[pse.o]: 8 symbols imported.
LIBRARY: Shared object libc.a[dl.o]: 4 symbols imported.
LIBRARY: Shared object libc.a[pty.o]: 1 symbols imported.
LIBRARY: Shared object libc.a[cthread.o]: 25 symbols imported.
LIBRARY: Shared object libc.a[uchar.o]: 4 symbols imported.
FILELIST: Number of previously inserted files processed: 73
(ld): exports /tmp//ccsv1Vg9.x
EXPORTS: Symbols exported: 312
(ld): initfini _GLOBAL__FI_stats_so _GLOBAL__FD_stats_so
(ld): resolve
RESOLVE: 1325 of 6197 symbols were kept.
(ld): addgl /usr/lib/glink.o
ADDGL: Glink code added for 505 symbols.
(ld): mismatch
MISMATCH: No type mismatches exist.
(ld): comprld
COMPRLD: Kept 10401 of 10401 relocation entries.
(ld): origin page 0x10000000 0x20000000
(ld): libpath /opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4:/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/../../..:/usr/lib:/lib
LIBPATH: Library path set to
/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4:/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/../../..:/usr/lib:/lib
(ld): save SRE .
SAVE: Section sizes = 575900+12696+860 (0x8C99C+0x3198+0x35C hex)
SAVE: Size of TOC: 4016 (0xFB0 hex)
SAVE: No .loader section relocation entries exist for the .text section.
(ld): rc
RC: Highest return code was 0.

This is the same in all cases:
EXPORTS: Symbols exported: 312

but we have different SIZES:
1) SAVE: Section sizes = 582204+13364+884 (0x8E23C+0x3434+0x374 hex)
2) SAVE: Section sizes = 624252+44524+1128 (0x9867C+0xADEC+0x468 hex)
3) SAVE: Section sizes = 575900+12696+860 (0x8C99C+0x3198+0x35C hex)

The size of the TOC varies accordingly.

Now, for a final test - remove all the -Wl,... options except for the
argument -G (-Wl,-G) and see what we get:

gcc -Wl,-bnoquiet -std=gnu99 -Wl,-G -o stats.so init.o kmeans.o
ansari.o bandwidths.o chisqsim.o d2x2xk.o fexact.o kendall.o ks.o
line.o smooth.o prho.o swilk.o ksmooth.o loessc.o monoSpl.o isoreg.o
Srunmed.o dblcen.o distance.o hclust-utils.o nls.o rWishart.o
HoltWinters.o PPsum.o arima.o burg.o filter.o mAR.o pacf.o starma.o
port.o family.o sbart.o approx.o loglin.o lowess.o massdist.o
splines.o lm.o complete_cases.o cov.o deriv.o fft.o fourier.o model.o
optim.o optimize.o integrate.o random.o distn.o zeroin.o rcont.o
influence.o bsplvd.o bvalue.o bvalus.o loessf.o ppr.o qsbart.o sgram.o
sinerp.o sslvrg.o stxwx.o hclust.o kmns.o eureka.o stl.o portsrc.o
lminfl.o

(ld): i stl.o
(ld): i portsrc.o
(ld): i lminfl.o
(ld): i /opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/libgcc.a
(ld): i /opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/libgcc_eh.a
(ld): lib /usr/lib/libc.a
LIBRARY: Shared object libc.a[shr.o]: 3287 symbols imported.
LIBRARY: Shared object libc.a[meth.o]: 2 symbols imported.
LIBRARY: Shared object libc.a[posix_aio.o]: 20 symbols imported.
LIBRARY: Shared object libc.a[aio.o]: 18 symbols imported.
LIBRARY: Shared object libc.a[pse.o]: 8 symbols imported.
LIBRARY: Shared object libc.a[dl.o]: 4 symbols imported.
LIBRARY: Shared object libc.a[pty.o]: 1 symbols imported.
LIBRARY: Shared object libc.a[cthread.o]: 25 symbols imported.
LIBRARY: Shared object libc.a[uchar.o]: 4 symbols imported.
FILELIST: Number of previously inserted files processed: 74
(ld): resolve
RESOLVE: 29 of 6161 symbols were kept.
(ld): addgl /usr/lib/glink.o
ADDGL: Glink code added for 2 symbols.
(ld): mismatch
MISMATCH: No type mismatches exist.
(ld): comprld
COMPRLD: Kept 36 of 36 relocation entries.
(ld): origin page 0x10000000 0x20000000
(ld): libpath /opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4:/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/../../..:/usr/lib:/lib
LIBPATH: Library path set to
/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4:/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/../../..:/usr/lib:/lib
(ld): save SRE .
SAVE: Section sizes = 680+240+4 (0x2A8+0xF0+0x4 hex)
SAVE: Size of TOC: 68 (0x44 hex)
SAVE: No .loader section relocation entries exist for the .text section.
(ld): rc
RC: Highest return code was 0.

Note the SIZES:
SAVE: Section sizes = 680+240+4 (0x2A8+0xF0+0x4 hex)
SAVE: Size of TOC: 68 (0x44 hex)

** If stats.so is shareable - we will see a header
root at x072:[/data/prj/cran/32/R-3.1.3.1/src/library/stats/src]dump -H stats.so

stats.so:

                        ***Loader Section***
                      Loader Header Information
VERSION#         #SYMtableENT     #RELOCent        LENidSTR
0x00000001       0x00000007       0x0000000e       0x00000080

#IMPfilID        OFFidSTR         LENstrTBL        OFFstrTBL
0x00000003       0x00000170       0x0000002a       0x000001f0


                        ***Import File Strings***
INDEX  PATH                          BASE                MEMBER
0      /opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4:/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/../../..:/usr/lib:/lib

Looking at the symbols in stats.so - this is now too far "the other way"

-G means

(ld): halt 4
(ld): setopt r/o->w
(ld): setopt nodelcsect
(ld): setopt noautoexp
(ld): setopt rtl
(ld): setopt nortllib
(ld): setopt symbolic:0
(ld): setfflag 4
(ld): savename stats.so
(ld): filelist 74 1
(ld): setopt noprogram
** OOPS - we do not want to load crt0.o and/or init.o I think!
(ld): i /lib/crt0.o
(ld): i init.o

Just adding -Wl,-bnoentry does not suffice, so... adding -Wl-bexpall
gives us some body:

(ld): lib /usr/lib/libc.a
LIBRARY: Shared object libc.a[shr.o]: 3287 symbols imported.
LIBRARY: Shared object libc.a[meth.o]: 2 symbols imported.
LIBRARY: Shared object libc.a[posix_aio.o]: 20 symbols imported.
LIBRARY: Shared object libc.a[aio.o]: 18 symbols imported.
LIBRARY: Shared object libc.a[pse.o]: 8 symbols imported.
LIBRARY: Shared object libc.a[dl.o]: 4 symbols imported.
LIBRARY: Shared object libc.a[pty.o]: 1 symbols imported.
LIBRARY: Shared object libc.a[cthread.o]: 25 symbols imported.
LIBRARY: Shared object libc.a[uchar.o]: 4 symbols imported.
FILELIST: Number of previously inserted files processed: 74
(ld): resolve
RESOLVE: 1324 of 6388 symbols were kept.
(ld): addgl /usr/lib/glink.o
ADDGL: Glink code added for 505 symbols.
(ld): mismatch
MISMATCH: No type mismatches exist.
(ld): comprld
COMPRLD: Kept 10394 of 10394 relocation entries.
(ld): origin page 0x10000000 0x20000000
(ld): libpath /opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4:/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/../../..:/usr/lib:/lib
LIBPATH: Library path set to
/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4:/opt/lib/gcc/powerpc-ibm-aix5.3.0.0/4.7.4/../../..:/usr/lib:/lib
(ld): save SRE .
SAVE: Section sizes = 575596+12560+872 (0x8C86C+0x3110+0x368 hex)
SAVE: Size of TOC: 4012 (0xFAC hex)
SAVE: No .loader section relocation entries exist for the .text section.
(ld): rc
RC: Highest return code was 0.
root at x072:[/data/prj/cran/32/R-3.1.3.1/src/library/stats/src]ls -l stats.so
-rwxr-xr-x    1 root     system      1456186 Oct 24 17:36 stats.so


On Sun, Oct 18, 2015 at 9:06 PM, aixtools <aixtools at gmail.com> wrote:
> On 2015-10-15 15:02, Prof Brian Ripley wrote:
>>
>> On 15/10/2015 13:32, Michael Felt wrote:
>>>
>>> Hi.
>>>
>>> Just wanted to let you know I am getting close to packaging R for AIX in
>
> rephrase - would like to be active in keeping R binaries current for AIX. My
> interest in not in R per se (rather a colleague who has a project that uses
> R, so I hope to assist him, and others like him).
>>
>>
>> Which version? (You mentioned 3.1.3 and 3.2.2 far below.)  There is little
>> value in reporting on frozen branches, and most value in reporting on
>> R-devel where all the current changes have been incorporated.
>
> The reason for reporting old and current releases is to understand what is
> new between releases, and what has been around for "awhile".
>
> Note: in the future I shall edit all the "you cannot build, could not
> determine ... messages" - and as much as possible, shall focus on R-devel
> "packaging".
>
> I (attempt to) 'package' a lot of Opensource tools for AIX. Generally, the
> problems are not application code related (sometimes a function available on
> one platform, e.g. Linux, but not on AIX) - but most are, or can be
> resolved, with modifications via configure.ac, Makefile.in, etc..
>
> Sincerely,
> Michael
>
> "Details"...
>
> When configure does complete - config.log starts with:
> It was created by R configure 3.1.3, which was
> generated by GNU Autoconf 2.69.  Invocation command line was
>
>   $ ./configure --prefix=/opt --sysconfdir=/var/R/etc
> --sharedstatedir=/var/R/com --localstatedir=/var/R --mandir=/usr/share/man
> --infodir=/opt/share/info/R --with-readline=no --with-x=no
>
> As I see you are using a recent autoconf (and I shall guess a recent
> automake) I would like to try a more version of libtool and see if that
> corrects anything. However, even in R-devel I do not see, directly, how you
> are using these tools (some projects include either a setup.sh or a
> buildconf script to standardize how the project does this.) I am quite
> capable of just calling the tools in sequence, but would prefer to follow
> your procedure.
> I
> Starting again - fresh 3.1.3, 3.2.2 and R-devel - all in 32-bit mode, for
> the start. The goal is a 64-bit build so that memory management will be
> easier.
>
> This is my "standard command for building a package"
>
> CPPFLAGS="-I/opt/buildaix/include -I/opt/include" CFLAGS="-I/opt/include
> -I/opt/buildaix/include -O2" ./configure \
>                 --prefix=/opt  \
>                 --sysconfdir=/var/R/etc \
>                 --sharedstatedir=/var/R/com \
>                 --localstatedir=/var/R \
>                 --mandir=/usr/share/man \
>                 --infodir=/opt/share/info/R --with-readline=no --with-x=no
> Results for 3.1.3
> configure: WARNING: you cannot build PDF versions of the R manuals
> configure: WARNING: you cannot build PDF versions of vignettes and help
> pages
> configure: WARNING: you cannot build info or HTML versions of the R manuals
> configure: WARNING: I could not determine a browser
> configure: WARNING: I could not determine a PDF viewer
> configure: WARNING: you cannot build info or HTML versions of the R manuals
> configure: WARNING: you cannot build PDF versions of the R manuals
> configure: WARNING: you cannot build PDF versions of vignettes and help
> pages
> configure: WARNING: I could not determine a browser
> configure: WARNING: I could not determine a PDF viewer
> + make > .buildaix/make.out
> sys-std.c: In function 'Rstd_ChooseFile':
> sys-std.c:1186:5: warning: implicit declaration of function 'isspace'
> [-Wimplicit-function-declaration]
> connections.c: In function 'fifo_open':
> connections.c:885:5: warning: implicit declaration of function 'open'
> [-Wimplicit-function-declaration]
> main.c: In function 'dummy_ii':
> main.c:1594:5: warning: function returns address of local variable [enabled
> by default]
> 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.
> Warning in solve.default(rgb) :
>   unable to load shared object
> '/data/prj/cran/32/R-3.1.3/modules//lapack.so':
>   rtld: 0712-001 Symbol logf was referenced
>       from module /data/prj/cran/32/R-3.1.3/lib/libRlapack.so(), but a
> runtime definition
>             of the symbol was not found.
> Error in solve.default(rgb) : LAPACK routines cannot be loaded
> Error: unable to load R code in package 'grDevices'
> Execution halted
> make: 1254-004 The error code from the last command is 1.
>
> ...
>
> Stop.
> make returned an error
> root at x072:[/data/prj/cran/32/R-3.1.3]
> ++++++
> Notes: Last April I was successful with building R - I do not recall
> specifically how I changed the release. I shall determine what I did to get
> it to build normally.
> ++++++
> Results for 3.2.2
> configure: WARNING: you cannot build PDF versions of the R manuals
> configure: WARNING: you cannot build PDF versions of vignettes and help
> pages
> configure: WARNING: you cannot build info or HTML versions of the R manuals
> configure: WARNING: I could not determine a browser
> configure: WARNING: I could not determine a PDF viewer
> configure: WARNING: you cannot build info or HTML versions of the R manuals
> configure: WARNING: you cannot build PDF versions of the R manuals
> configure: WARNING: you cannot build PDF versions of vignettes and help
> pages
> configure: WARNING: I could not determine a browser
> configure: WARNING: I could not determine a PDF viewer
> + make > .buildaix/make.out
> sys-std.c: In function 'Rstd_ChooseFile':
> sys-std.c:1189:5: warning: implicit declaration of function 'isspace'
> [-Wimplicit-function-declaration]
> connections.c: In function 'fifo_open':
> connections.c:876:5: warning: implicit declaration of function 'open'
> [-Wimplicit-function-declaration]
> main.c: In function 'dummy_ii':
> main.c:1598:5: warning: function returns address of local variable [enabled
> by default]
> 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: LoadInitFile
> ld: 0711-224 WARNING: Duplicate symbol: BM_norm_keep
> ld: 0711-224 WARNING: Duplicate symbol: N01_kind
> ld: 0711-224 WARNING: Duplicate symbol: R_ReadItemDepth
> ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
> information.
> 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: LoadInitFile
> ld: 0711-224 WARNING: Duplicate symbol: BM_norm_keep
> ld: 0711-224 WARNING: Duplicate symbol: N01_kind
> ld: 0711-224 WARNING: Duplicate symbol: R_ReadItemDepth
> ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
> information.
> 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.
> /bin/sh: There is no process to read data written to a pipe.
> Warning in solve.default(rgb) :
>   unable to load shared object
> '/data/prj/cran/32/R-3.2.2/modules//lapack.so':
>   rtld: 0712-001 Symbol logf was referenced
>       from module /data/prj/cran/32/R-3.2.2/lib/libRlapack.so(), but a
> runtime definition
>             of the symbol was not found.
> Error in solve.default(rgb) : LAPACK routines cannot be loaded
> Error: unable to load R code in package 'grDevices'
> Execution halted
> make: 1254-004 The error code from the last command is 1.
>
> ...
> make returned an error
> +++++
> Here there are similiar - and new problems. The error re: rtld is usually a
> compiler (actually ld) flag error - a routine is expected to be exported in
> a shared object, but the object is still "static".
> I have seen this same problem with at least one R module.
>
> I still am unsure why some functions are being defined double - that info
> will come later
> root at x072:[/data/prj/cran/32/R-3.2.2]
>
> +++++
> From  R-devel_2015-10-17.tar.bz2
> configure: WARNING: you cannot build PDF versions of the R manuals
> configure: WARNING: you cannot build PDF versions of vignettes and help
> pages
> configure: WARNING: you cannot build info or HTML versions of the R manuals
> configure: WARNING: I could not determine a browser
> configure: WARNING: I could not determine a PDF viewer
> configure: error: bzip2 library and headers are required
> buildaix: ./configure ... returned an error
>
> try doing "grep configure: config.log | tail" for possible explanation
>
> try "./configure --help" for additional arguments to buildaix
> ++++ config.log configure: comments are ++++
> configure:35647: checking bzlib.h presence
> configure:35647: gcc -E -I/opt/buildaix/include -I/opt/include  conftest.c
> configure:35647: $? = 1
> configure: failed program was:
> configure:35647: result: no
> configure:35647: checking for bzlib.h
> configure:35647: result: no
> configure:35712: checking whether bzip2 support suffices
> configure:35719: error: bzip2 library and headers are required
> configure: exit 1
> ++++ ++++
> Here is a completely new kind of "problem" - a demand for an include file.
> bzip2 is available, but configure is looking for it in a different way and
> now configure fails.
>
>>
>>> 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:
>>
>>
>> R-devel has 2.4.6 .
>>
>>> I am hoping a new libtool will clean up most of the manual work now
>>> needed.
>>
>>
>> But libtool is hardly used in building R.
>>
>>> # 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"
>>
>>
>> See the manual: flags such as -maix64 should be part of CC, not CFLAGS.
>> That explains a lot of what was reported.
>> Specifically,
>> https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Essential-programs-and-libraries
>> and https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#AIX .
>>
>> It is safer to put such things on the configure command line or in a
>> config.site file (they will be found when updating if you do).
>>
>> [Lots of test output removed.]
>>
>



[Rd] Building R for AIX in 32-bit mode - as preparation for building in 64-bit mode (changed subject!) - INFO/FEEDBACK - do not read as a bug report!
Michael Felt