Bug 16633 - duplicate symbols in tools.so, grDevices.so, graphics.so and libR.so - where should they really be?
Summary: duplicate symbols in tools.so, grDevices.so, graphics.so and libR.so - where ...
Status: UNCONFIRMED
Alias: None
Product: R
Classification: Unclassified
Component: Installation (show other bugs)
Version: R-devel (trunk)
Hardware: PowerPC AIX
: P5 enhancement
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2015-12-15 15:12 UTC by Michael Felt
Modified: 2016-04-09 14:39 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Felt 2015-12-15 15:12:14 UTC
The following messages remain:

../scripts/R-devel-make.text:747:ld: 0711-224 WARNING: Duplicate symbol: Rf_yylval
../scripts/R-devel-make.text:748:ld: 0711-224 WARNING: Duplicate symbol: Rf_yychar
../scripts/R-devel-make.text:749:ld: 0711-224 WARNING: Duplicate symbol: Rf_yynerrs
../scripts/R-devel-make.text:851:ld: 0711-224 WARNING: Duplicate symbol: baseRegisterIndex
../scripts/R-devel-make.text:888:ld: 0711-224 WARNING: Duplicate symbol: .Rf_dpptr
../scripts/R-devel-make.text:889:ld: 0711-224 WARNING: Duplicate symbol: baseRegisterIndex
../scripts/R-devel-make.text:890:ld: 0711-224 WARNING: Duplicate symbol: Rf_dpptr

## ** The first three are in tools.so - I expect they are meant to 'be' here, but need direction to be sure:

root@x065:[/data/prj/cran/R-devel/src/library/tools/src]grep -c yylval * | grep -v :0
gramLatex.c:20
gramLatex.y:11
gramRd.c:20
gramRd.y:11

root@x065:[/data/prj/cran/32/R-shared/src/main]nm -Ae *o | grep Rf_yy
gram.o:   .Rf_yyparse          T       30528       11420
gram.o:   Rf_yychar            B       56712           4
gram.o:   Rf_yychar            d       56604           4
gram.o:   Rf_yylval            B       56708           4
gram.o:   Rf_yylval            d       56480           4
gram.o:   Rf_yynerrs           B       56664           4
gram.o:   Rf_yynerrs           d       56600           4
gram.o:   Rf_yyparse           D       56180
gram.o:   Rf_yyparse           d       56180          12
libR.so:  .Rf_yyparse          T   269419804       11420
libR.so:  .Rf_yyparse          T   270579520
libR.so:  .Rf_yyparse          t   270579520          40
libR.so:  Rf_yychar            B   537767996           4
libR.so:  Rf_yychar            d   537100116           4
libR.so:  Rf_yylval            B   537767928           4
libR.so:  Rf_yylval            d   537100020           4
libR.so:  Rf_yynerrs           B   537767992           4
libR.so:  Rf_yynerrs           d   537100112           4
libR.so:  Rf_yyparse           D   537090136
libR.so:  Rf_yyparse           d   537090136          12
libR.so:  Rf_yyparse           d   537111476           4

## ** baseRegisterIndex is in libR.so, grDevices.so and graphics.so
## ** Rf_dpptr is in libR.so and graphics.so

## *** It seems that baseRegisterIndex is defined in a .h file...

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}
 ------------------------- -------------------------------------------------
 baseRegisterIndex         /data/prj/cran/R-devel/src/library/grDevices/src/devices.c(devices.o)
    ** Duplicate **        {../../../../lib/libR.so}

root@x065:[/data/prj/cran/32/R-shared/src/library/grDevices/src]grep -c baseRegisterIndex         /data/prj/cran/R-devel/src/library/grDevices/src/* | grep -v :0
root@x065:[/data/prj/cran/32/R-shared/src/library/grDevices/src]

# 36 "/data/prj/cran/R-devel/src/library/grDevices/src/devices.c" 2
# 1 "/data/prj/cran/R-devel/src/include/GraphicsBase.h" 1
# 27 "/data/prj/cran/R-devel/src/include/GraphicsBase.h"
typedef struct {
    GPar dp;

    GPar gp;
    GPar dpSaved;




    Rboolean baseDevice;
} baseSystemState;

void registerBase(void);
void unregisterBase(void);

void Rf_setBaseDevice(Rboolean val, pGEDevDesc dd);

int baseRegisterIndex;
# 37 "/data/prj/cran/R-devel/src/library/grDevices/src/devices.c" 2
# 53 "/data/prj/cran/R-devel/src/library/grDevices/src/devices.c"


## *** devices.o (libR.so) and base.o (graphics.so) are the proud owners of the duplicate symbols:

root@x065:[/data/prj/cran/32/R-shared/src/main]nm -Ae *o | grep  Rf_dpptr
devices.o: .Rf_dpptr            T           0         104
devices.o: Rf_dpptr             D        7540
devices.o: Rf_dpptr             d        7540          12
libR.so:  .Rf_dpptr            T   270277704         104
libR.so:  .Rf_dpptr            T   270562140
libR.so:  .Rf_dpptr            t   270562140          40
libR.so:  Rf_dpptr             D   537087496
libR.so:  Rf_dpptr             d   537087496          12
libR.so:  Rf_dpptr             d   537110192           4

root@x065:[/data/prj/cran/32/R-shared/src/library/graphics/src]nm -Ae *o | grep  Rf_dpptr
base.o:   .Rf_dpptr            T         384         108
base.o:   Rf_dpptr             D        5804
base.o:   Rf_dpptr             d        5804          12
graphics.o: .Rf_dpptr            U           -
graphics.so: .Rf_dpptr            T   268439932         108
graphics.so: .Rf_dpptr            T   268687540
graphics.so: .Rf_dpptr            t   268687540          40
graphics.so: Rf_dpptr             D   536903524
graphics.so: Rf_dpptr             d   536903524          12
graphics.so: Rf_dpptr             d   536906164           4
par.o:    .Rf_dpptr            U           -
plot.o:   .Rf_dpptr            U           -

## **** Again, it seems that it will be found in an include file...

root@x065:[/data/prj/cran/R-devel/src/library/graphics/src]grep Rf_dpptr *
root@x065:[/data/prj/cran/R-devel/src/library/graphics/src]

Well, sort of:

  +380  /* FIXME: Make this a macro to avoid function call overhead?
  +381     Inline it if you really think it matters.
  +382   */
  +383  GPar* gpptr(pGEDevDesc dd) {
  +384      if (baseRegisterIndex == -1)
  +385          error(_("the base graphics system is not registered"));
  +386      baseSystemState *bss = dd->gesd[baseRegisterIndex]->systemSpecific;
  +387      return &(bss->gp);
  +388  }
  +389
  +390  GPar* dpptr(pGEDevDesc dd) {
  +391      if (baseRegisterIndex == -1)
  +392          error(_("the base graphics system is not registered"));
  +393      baseSystemState *bss = dd->gesd[baseRegisterIndex]->systemSpecific;
  +394      return &(bss->dp);
  +395  }
  +396
  +397  /* called in GNewPlot to mark device as 'dirty' */
  +398  void Rf_setBaseDevice(Rboolean val, pGEDevDesc dd) {
  +399      if (baseRegisterIndex == -1)
  +400          error(_("the base graphics system is not registered"));
  +401      baseSystemState *bss = dd->gesd[baseRegisterIndex]->systemSpecific;
  +402      bss->baseDevice = val;
  +403  }
"base.c" The cursor is at line 403 of 403 --100%-- .

becomes:
GPar* Rf_gpptr(pGEDevDesc dd) {
    if (baseRegisterIndex == -1)
 Rf_error(dgettext ("graphics", "the base graphics system is not registered"));
    baseSystemState *bss = dd->gesd[baseRegisterIndex]->systemSpecific;
    return &(bss->gp);
}

GPar* Rf_dpptr(pGEDevDesc dd) {
    if (baseRegisterIndex == -1)
 Rf_error(dgettext ("graphics", "the base graphics system is not registered"));
    baseSystemState *bss = dd->gesd[baseRegisterIndex]->systemSpecific;
    return &(bss->dp);
}


void Rf_setBaseDevice(Rboolean val, pGEDevDesc dd) {
    if (baseRegisterIndex == -1)
 Rf_error(dgettext ("graphics", "the base graphics system is not registered"));
    baseSystemState *bss = dd->gesd[baseRegisterIndex]->systemSpecific;
    bss->baseDevice = val;
}
"base.i" The cursor is at line 6798 of 6798 --100%-- .

Your call...

And, hope this helps!
Comment 1 Michael Felt 2015-12-17 13:09:29 UTC
This is FYI - still working -

I have been doing a bit of research - comparing Linux on Power, with AIX (on Power) - same machine, just a different OS.

On linux I see:

root@x066:/data/prj/cran/32/R-debian/lib# cd ../src/library/tools
root@x066:/data/prj/cran/32/R-debian/src/library/tools/src# nm -AB *o | grep Rf_yy[cln]                                                                                                         
gramLatex.o:00000004 C Rf_yychar
gramLatex.o:00000004 C Rf_yylval
gramLatex.o:00000004 C Rf_yynerrs
gramRd.o:00000004 C Rf_yychar
gramRd.o:00000004 C Rf_yylval
gramRd.o:00000004 C Rf_yynerrs
tools.so:00023dbc s Rf_yychar
tools.so:00023db4 s Rf_yylval
tools.so:00023db8 s Rf_yynerrs

On AIX I see:

rroot@x065:[/data/prj/cran/32/R-3.2.3/src/library/tools/src] nm -AB *o | grep Rf_yy[cln]
gramLatex.o:      16648 d Rf_yychar
gramLatex.o:      16728 B Rf_yychar
gramLatex.o:          0 - Rf_yychar:G-1
gramLatex.o:          - U Rf_yylval
gramLatex.o:      16652 d Rf_yylval
gramLatex.o:      16668 d Rf_yynerrs
gramLatex.o:      16696 B Rf_yynerrs
gramLatex.o:          0 - Rf_yynerrs:G-1
gramRd.o:      36508 d Rf_yychar
gramRd.o:      36604 B Rf_yychar
gramRd.o:          0 - Rf_yychar:G-1
gramRd.o:      36484 d Rf_yylval
gramRd.o:      36600 B Rf_yylval
gramRd.o:          0 - Rf_yylval:G495
gramRd.o:      36520 d Rf_yynerrs
gramRd.o:      36568 B Rf_yynerrs
gramRd.o:          0 - Rf_yynerrs:G-1
tools.so:  536875880 d Rf_yychar
tools.so:  536877240 B Rf_yychar
tools.so:          0 - Rf_yychar:G-1
tools.so:          0 - Rf_yychar:G-1
tools.so:  536875828 d Rf_yylval
tools.so:  536877236 B Rf_yylval
tools.so:          0 - Rf_yylval:G495
tools.so:  536875892 d Rf_yynerrs
tools.so:  536877272 B Rf_yynerrs
tools.so:          0 - Rf_yynerrs:G-1
tools.so:          0 - Rf_yynerrs:G-1
root@x065:[/data/prj/cran/32/R-3.2.3/src/library/tools/src]


Hence - it seems AIX method takes the following code quite literally:

Considering the following .i outputs:

aix/gramLatex.i:5647:extern SEXP Rf_yylval;
aix/gramLatex.i:6042:int Rf_yychar;
aix/gramLatex.i:6045:SEXP Rf_yylval;
aix/gramLatex.i:6053:int Rf_yynerrs;
aix/gramRd.i:6053:extern SEXP Rf_yylval;
aix/gramRd.i:6972:int Rf_yychar;
aix/gramRd.i:6975:SEXP Rf_yylval;
aix/gramRd.i:6983:int Rf_yynerrs;
debian/gramLatex.i:7373:extern SEXP Rf_yylval;
debian/gramLatex.i:7733:int Rf_yychar;
debian/gramLatex.i:7735:SEXP Rf_yylval ;
debian/gramLatex.i:7746:int Rf_yynerrs;
debian/gramRd.i:8682:extern SEXP Rf_yylval;
debian/gramRd.i:9517:int Rf_yychar;
debian/gramRd.i:9519:SEXP Rf_yylval ;
debian/gramRd.i:9530:int Rf_yynerrs;

More closely:
aix/gramLatex.i:5647:extern SEXP Rf_yylval;
aix/gramLatex.i:6045:SEXP Rf_yylval;            # seems to looking as a definition

debian/gramLatex.i:7373:extern SEXP Rf_yylval;
debian/gramLatex.i:7735:SEXP Rf_yylval ;        # looks global by definition

On AIX the variable is defined immedately, while on Linux that is postponed.

Michael
Comment 2 Rich Burridge 2016-04-09 14:39:10 UTC
On Solaris with R version 3.2.3, it was also noticed that baseRegisterIndex 
was multiply defined, at least in graphics.so and libR.so, and the former 
was "hidden".  Thus, any reference from graphics.so to baseRegisterIndex 
would bind to itself, whereas other references would bind to libR.so.  
There are effectively (at least) two instances of this symbol being used.   
Unsure whether this was intentional.  Perhaps there are no references from 
graphics.so to baseRegisterIndex, which makes the header induced definition 
harmless but unnecessary and perhaps confusing.  The "definition" of data 
items in headers with the use of "hidden" visibility can produce some hard 
to debug error conditions.