Skip to content

Commit

Permalink
Diagnose #49 0.8.3 fails to load on Linux/Mono
Browse files Browse the repository at this point in the history
  • Loading branch information
jmp75 committed May 3, 2020
1 parent 7e67885 commit dcbf6e9
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 2 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,13 @@ src/libfiles

inst/libs/*.*
inst/libs/i386/*.*

*.so

*.o

.ionide/

mono_crash.*.json

src/Makevars
43 changes: 43 additions & 0 deletions docs/devnotes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

Setting up native rClr.so debugging from vs code.

`launch.json`

```json
{
// Adapted from debugging a native lib loaded by Python
// https://code.visualstudio.com/docs/cpp/launch-json-reference
// Not used as such but looking like a useful source: https://www.justinmklam.com/posts/2017/10/vscode-debugger-setup/
// Maybe: https://marketplace.visualstudio.com/items?itemName=webfreak.debug
// https://stackoverflow.com/questions/31763639/how-to-prevent-gdb-from-loading-debugging-symbol-for-a-large-library
// I follow the instructions in https://developer.mozilla.org/en-US/docs/Archive/Mozilla/Using_gdb_on_wimpy_computers . May need adaptation to make it
// Nope. Need to use symbolLoadInfo below, but still stuck on libc6 exception
// https://gist.github.com/asroy/ca018117e5dbbf53569b696a8c89204f
"name": "(gdb) Attach to R session",
"type": "cppdbg",
"request": "attach",
// "program": "/home/per202/src/csiro/stash/water-apportionment-pk/fortran/lib/libwaa.so",
"program": "/usr/local/lib/R/bin/exec/R",
"processId": "${command:pickProcess}",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
// "cwd": "/home/per202/src/csiro/stash/water-apportionment-pk/fortran/lib",
"additionalSOLibSearchPath": "/home/per202/.local/lib/R/3.6.2/site-library/rClr/libs",
"symbolLoadInfo":{
"loadAll": false,
"exceptionList": "rClr.so"
},
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
```

```bash
export BUILDTYPE=Debug
R CMD INSTALL --no-test-load rClr
```
5 changes: 3 additions & 2 deletions src/Makevars.in
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ ifeq "$(BUILDTYPE)" "Release"
BuildConfiguration=Unix
else
BuildConfiguration=UnixDebug
GDEBUG_FLAGS = -ggdb3 -Og # See e.g. https://gcc.gnu.org/onlinedocs/gcc-4.5.4/gcc/Debugging-Options.html#Debugging-Options
endif ## ifeq "$(BUILDTYPE)" "Release"

PKG_CFLAGS_LOCAL=`pkg-config --cflags $(MONO_LIB) glib-2.0`
Expand Down Expand Up @@ -102,7 +103,7 @@ clean:
${RM} $(OBJECTS) $(SHLIB) $(RCLR_LIBS)

rClrMono.o:
$(CXX) -std=c++11 $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c rClr.cpp -o rClrMono.o -lsupc++
$(CXX) $(GDEBUG_FLAGS) -std=c++11 $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c rClr.cpp -o rClrMono.o -lsupc++
###### NOTE:
# On a CentOS OS, I needed to use the following. The CPP and C flags would otherwise return two options not understood:
# -xHOST -fp-model precise
Expand All @@ -111,7 +112,7 @@ rClrMono.o:
# $(CXX) -std=c++11 -I/apps/R/3.1.1/lib64/R/include -DNDEBUG -I/usr/local/include `pkg-config --cflags mono-2 glib-2.0` -g -D MONO_CLR -D MONO_INST -fpic -O3 -openmp -c rClr.cpp -o rClrMono.o -lsupc++

rClrMono$(SHLIB_EXT): rClrMono.o
$(CXX) -std=c++11 -shared -Wl,-z,relro -o rClrMono$(SHLIB_EXT) rClrMono.o $(ALL_LIBS)
$(CXX) $(GDEBUG_FLAGS) -std=c++11 -shared -Wl,-z,relro -o rClrMono$(SHLIB_EXT) rClrMono.o $(ALL_LIBS)

printarch:
-@echo **Variable information only for diagnosis purposes**
Expand Down
7 changes: 7 additions & 0 deletions src/rClr.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@

// #define RCLR_VER 0x000100 /* RCLR v0.1-0 */

// 202005 Temporarily to faciliate debugging from VSCode
#ifndef MONO_CLR
#ifdef __linux__
#define MONO_CLR
#endif
#endif

#ifndef MS_CLR
#ifndef MONO_CLR
#define MS_CLR 1
Expand Down

0 comments on commit dcbf6e9

Please sign in to comment.