Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .dev/cc.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ cc = function(test=FALSE, clean=FALSE, debug=FALSE, omp=!debug, cc_dir, path=Sys

# Make sure library .so is not loaded (neither installed package nor from dev)
dll = unlist(do.call("rbind",getLoadedDLLs())[,"path"])
dll = grep("datatable.so",dll,value=TRUE)
dll = grep("data_table.so",dll,value=TRUE)
sapply(dll, dyn.unload)
gc()

Expand All @@ -61,18 +61,18 @@ cc = function(test=FALSE, clean=FALSE, debug=FALSE, omp=!debug, cc_dir, path=Sys
if (clean) system("rm *.o *.so")
OMP = if (omp) "" else "no-"
if (debug) {
ret = system(sprintf("MAKEFLAGS='-j CC=%s PKG_CFLAGS=-f%sopenmp CFLAGS=-std=c99\\ -O0\\ -ggdb\\ -pedantic' R CMD SHLIB -d -o datatable.so *.c", CC, OMP))
ret = system(sprintf("MAKEFLAGS='-j CC=%s PKG_CFLAGS=-f%sopenmp CFLAGS=-std=c99\\ -O0\\ -ggdb\\ -pedantic' R CMD SHLIB -d -o data_table.so *.c", CC, OMP))
} else {
ret = system(sprintf("MAKEFLAGS='-j CC=%s CFLAGS=-f%sopenmp\\ -std=c99\\ -O3\\ -pipe\\ -Wall\\ -pedantic\\ -fno-common' R CMD SHLIB -o datatable.so *.c", CC, OMP))
ret = system(sprintf("MAKEFLAGS='-j CC=%s CFLAGS=-f%sopenmp\\ -std=c99\\ -O3\\ -pipe\\ -Wall\\ -pedantic\\ -fno-common' R CMD SHLIB -o data_table.so *.c", CC, OMP))
# TODO add -Wextra too?
}
if (ret) return()
# clang -Weverything includes -pedantic and issues many more warnings than gcc
# system("R CMD SHLIB -o datatable.so *.c")
# system("R CMD SHLIB -o data_table.so *.c")
if (any(sapply(objects(envir=.GlobalEnv),function(x){inherits(get(x,.GlobalEnv),"data.table")}))) {
cat("ABOUT TO RELOAD .SO BUT THERE ARE DATA.TABLE OBJECTS IN .GLOBALENV SO FINALIZER MIGHT CRASH\n")
}
dyn.load("datatable.so")
dyn.load("data_table.so")
setwd(old)
xx = getDLLRegisteredRoutines("datatable",TRUE)
for (i in seq_along(xx$.Call))
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
useDynLib(datatable, .registration=TRUE)
useDynLib("data_table", .registration=TRUE)

## For S4-ization
import(methods)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@

12. `?merge` and `?setkey` have been updated to clarify that the row order is retained when `sort=FALSE`, and why `NA`s are always first when `sort=TRUE`, [#2574](https://github.com/Rdatatable/data.table/issues/2574) [#2594](https://github.com/Rdatatable/data.table/issues/2594). Thanks to Davor Josipovic and Markus Bonsch for the reports, and Jan Gorecki for the PR.

13. `datatable.[dll|so]` has changed name to `data_table.[dll|so]`, [#4442](https://github.com/Rdatatable/data.table/pull/4442). Thanks to Jan Gorecki for the PR. We had previously removed the `.` since `.` is not allowed by the following paragraph in the Writing-R-Extensions manual. Replacing `.` with `_` instead now seems more consistent with the last sentence.

> ... the basename of the DLL needs to be both a valid file name and valid as part of a C entry point (e.g. it cannot contain ‘.’): for portable code it is best to confine DLL names to be ASCII alphanumeric plus underscore. If entry point R_init_lib is not found it is also looked for with ‘.’ replaced by ‘_’.


# data.table [v1.14.0](https://github.com/Rdatatable/data.table/milestone/23?closed=1) (21 Feb 2021)

Expand Down
9 changes: 3 additions & 6 deletions R/onLoad.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@
# Runs when loaded but not attached to search() path; e.g., when a package just Imports (not Depends on) data.table
if (!exists("test.data.table", .GlobalEnv, inherits=FALSE)) {
# check when installed package is loaded but skip when developing the package with cc()
dllV = if (is.loaded("CdllVersion",PACKAGE="datatable")) .Call(CdllVersion) else "before 1.12.0"
# ^^ no dot as this is the name of the dll file, #3282
dllV = if (is.loaded("CdllVersion",PACKAGE="data_table")) .Call(CdllVersion) else "before 1.12.0"
RV = packageVersion("data.table")
if (dllV != RV) {
dll = if (.Platform$OS.type=="windows") "dll" else "so"
# https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17478
stopf("The datatable.%s version (%s) does not match the package (%s). Please close all R sessions to release the old %s and reinstall data.table in a fresh R session. The root cause is that R's package installer can in some unconfirmed circumstances leave a package in a state that is apparently functional but where new R code is calling old C code silently: https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17478. Once a package is in this mismatch state it may produce wrong results silently until you next upgrade the package. Please help by adding precise circumstances to 17478 to move the status to confirmed. This mismatch between R and C code can happen with any package not just data.table. It is just that data.table has added this check.", dll, dllV, RV, toupper(dll))
stopf("The data_table.%s version (%s) does not match the package (%s). Please close all R sessions to release the old %s and reinstall data.table in a fresh R session. The root cause is that R's package installer can in some unconfirmed circumstances leave a package in a state that is apparently functional but where new R code is calling old C code silently: https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17478. Once a package is in this mismatch state it may produce wrong results silently until you next upgrade the package. Please help by adding precise circumstances to 17478 to move the status to confirmed. This mismatch between R and C code can happen with any package not just data.table. It is just that data.table has added this check.", dll, dllV, RV, toupper(dll))
}
builtUsing = readRDS(system.file("Meta/package.rds",package="data.table"))$Built$R
if (!identical(base::getRversion()>="4.0.0", builtUsing>="4.0.0")) {
Expand Down Expand Up @@ -137,9 +136,7 @@ getRversion = function(...) stopf("Reminder to data.table developers: don't use
# 4) Defining getRversion with a stopf() here helps prevent new switches on getRversion() being added in future. Easily circumvented but the point is to issue the message above.

.onUnload = function(libpath) {
# fix for #474. the shared object name is different from package name
# So 'detach' doesn't find datatable.so, as it looks by default for data.table.so
library.dynam.unload("datatable", libpath)
library.dynam.unload("data_table", libpath)
}

# nocov end
6 changes: 3 additions & 3 deletions src/Makevars.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PKG_LIBS = @PKG_LIBS@ @openmp_cflags@ @zlib_libs@
# Note that -lz is now escaped via @zlib_libs@ when zlib is not installed

all: $(SHLIB)
@echo PKG_CFLAGS = $(PKG_CFLAGS)
@echo PKG_CFLAGS = $(PKG_CFLAGS)
@echo PKG_LIBS = $(PKG_LIBS)
if [ "$(SHLIB)" != "datatable$(SHLIB_EXT)" ]; then mv $(SHLIB) datatable$(SHLIB_EXT); fi
if [ "$(OS)" != "Windows_NT" ] && [ `uname -s` = 'Darwin' ]; then install_name_tool -id datatable$(SHLIB_EXT) datatable$(SHLIB_EXT); fi
if [ "$(SHLIB)" != "data_table$(SHLIB_EXT)" ]; then mv $(SHLIB) data_table$(SHLIB_EXT); fi
if [ "$(OS)" != "Windows_NT" ] && [ `uname -s` = 'Darwin' ]; then install_name_tool -id data_table$(SHLIB_EXT) data_table$(SHLIB_EXT); fi
2 changes: 1 addition & 1 deletion src/Makevars.win
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ PKG_CFLAGS = $(SHLIB_OPENMP_CFLAGS)
PKG_LIBS = $(SHLIB_OPENMP_CFLAGS) -lz

all: $(SHLIB)
mv $(SHLIB) datatable$(SHLIB_EXT)
mv $(SHLIB) data_table$(SHLIB_EXT)
5 changes: 2 additions & 3 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,7 @@ static void setSizes() {
// One place we need the largest sizeof is the working memory malloc in reorder.c
}

void attribute_visible R_init_datatable(DllInfo *info)
// relies on pkg/src/Makevars to mv data.table.so to datatable.so
void attribute_visible R_init_data_table(DllInfo *info)
{
// C exported routines
// must be also listed in inst/include/datatableAPI.h
Expand Down Expand Up @@ -376,7 +375,7 @@ inline long long DtoLL(double x) {
// under clang 3.9.1 -O3 and solaris-sparc but not solaris-x86 or gcc.
// There is now a grep in CRAN_Release.cmd; use this union method instead.
// int64_t may help rather than 'long long' (TODO: replace all long long with int64_t)
// The two types must be the same size. That is checked in R_init_datatable (above)
// The two types must be the same size. That is checked in R_init_data_table (above)
// where sizeof(int64_t)==sizeof(double)==8 is checked.
// Endianness should not matter because whether big or little, endianness is the same
// inside this process, and the two types are the same size.
Expand Down