I've a solution and going to post it here for reference for other people.
I've begun experimenting with the produced shared library armatest.so by loading/unloading it using R function
dyn.load/dyn.unload. The functions seemed to work correctly, but when using
lsof on my R process, I've noticed that the library remained loaded. So
dyn.unload was not actually unloading the library, and it remained mapped in the process memory.
Following suggestions in this thread:
https://github.com/kaskr/adcomp/issues/27I've ran readelf on the shared library, and sure enough it contained symbols labeled UNIQUE:
$ readelf -s armatest.so | grep UNIQUE
118: 000000000020d248 8 OBJECT UNIQUE DEFAULT 24 _ZZN4arma16arma_stream_er
127: 000000000020d7c8 8 OBJECT UNIQUE DEFAULT 25 _ZN4arma5DatumIdE3nanE
133: 000000000020d240 8 OBJECT UNIQUE DEFAULT 24 _ZZN4arma16arma_stream_er
182: 000000000020d7c0 8 OBJECT UNIQUE DEFAULT 25 _ZGVN4arma5DatumIdE3nanE
179: 000000000020d240 8 OBJECT UNIQUE DEFAULT 24 _ZZN4arma16arma_stream_er
211: 000000000020d7c0 8 OBJECT UNIQUE DEFAULT 25 _ZGVN4arma5DatumIdE3nanE
214: 000000000020d248 8 OBJECT UNIQUE DEFAULT 24 _ZZN4arma16arma_stream_er
262: 000000000020d7c8 8 OBJECT UNIQUE DEFAULT 25 _ZN4arma5DatumIdE3nanE
Again from the above thread, I've added this to my Makevars, and the problem disappeared!:
PKG_CXXFLAGS=-fno-gnu-unique
With this flag I'm now able to reload the library using
devtools::load_all and all my changes take effect immediately. No more restarting R after changing C++ code.
-Mike