K2InformaticsGmbH / oranif

Oracle OCI driver using dirty NIF
Apache License 2.0
4 stars 2 forks source link

nix compile optimizations #79

Closed c-bik closed 5 years ago

c-bik commented 5 years ago

@acautin

there are still some warnings (maybe outside the scope of this pr)

Also with -O2 in CentOs6

$ make -f c_src/Makefile
cd c_src/odpi && make
make[1]: Entering directory `/home/bikram/projects/oranif/c_src/odpi'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/bikram/projects/oranif/c_src/odpi'
gcc -o priv/dpi_nif.so -ggdb -O2 -Wall -fPIC -shared -std=c11 -Ic_src -I"/usr/lib/erlang/erts-9.2/include" -I"c_src/
odpi/include" -Lc_src/odpi/lib c_src/dpiConn_nif.c c_src/dpiContext_nif.c c_src/dpiData_nif.c c_src/dpi_nif.c c_src/
dpiQueryInfo_nif.c c_src/dpiStmt_nif.c c_src/dpiVar_nif.c -lodpic
c_src/dpiConn_nif.c: In function ‘conn_close’:
c_src/dpiConn_nif.c:317:18: warning: ‘m’ may be used uninitialized in this function [-Wmaybe-uninitialized]
c_src/dpiStmt_nif.c: In function ‘stmt_execute’:
c_src/dpiStmt_nif.c:42:18: warning: ‘m’ may be used uninitialized in this function [-Wmaybe-uninitialized]
c_src/dpiStmt_nif.c: In function ‘stmt_bindValueByPos’:
c_src/dpiStmt_nif.c:187:5: warning: ‘bindType’ may be used uninitialized in this function [-Wmaybe-uninitialized]
c_src/dpiStmt_nif.c: In function ‘stmt_bindValueByName’:
c_src/dpiStmt_nif.c:213:5: warning: ‘bindType’ may be used uninitialized in this function [-Wmaybe-uninitialized]
c_src/dpiStmt_nif.c: In function ‘stmt_defineValue’:
c_src/dpiStmt_nif.c:332:5: warning: ‘nativeType’ may be used uninitialized in this function [-Wmaybe-uninitialized]
c_src/dpiStmt_nif.c:332:5: warning: ‘oraType’ may be used uninitialized in this function [-Wmaybe-uninitialized]
c-bik commented 5 years ago

@acautin Can you please try once more with Mac?

acautin commented 5 years ago

@c-bik this is how it looks now in OS X:

cd c_src/odpi && make
make[1]: Nothing to be done for `all'.
gcc -o priv/dpi_nif.so -Ic_src -I"/Users/agustin/kerl/20.2/erts-9.2/include" -I"c_src/odpi/include" -O2 -ggdb -Wall -fPIC -std=c11 -dynamiclib  c_src/dpiConn_nif.c c_src/dpiContext_nif.c c_src/dpiData_nif.c c_src/dpiQueryInfo_nif.c c_src/dpiStmt_nif.c c_src/dpiVar_nif.c c_src/dpi_nif.c -Lc_src/odpi/lib -shared -lodpic -flat_namespace -undefined suppress
c_src/dpiData_nif.c:187:39: warning: incompatible pointer types passing 'int64_t *' (aka 'long long *') to parameter of type 'long *' [-Wincompatible-pointer-types]
    if (!enif_get_int64(env, argv[1], &amount))
                                      ^~~~~~~
/Users/agustin/kerl/20.2/erts-9.2/include/erl_nif_api_funcs.h:104:79: note: passing argument to parameter 'ip' here
ERL_NIF_API_FUNC_DECL(int,enif_get_long,(ErlNifEnv*, ERL_NIF_TERM term, long* ip));
                                                                              ^
1 warning generated.
c-bik commented 5 years ago

@acautin

@c-bik this is how it looks now in OS X:

cd c_src/odpi && make
make[1]: Nothing to be done for `all'.
gcc -o priv/dpi_nif.so -Ic_src -I"/Users/agustin/kerl/20.2/erts-9.2/include" -I"c_src/odpi/include" -O2 -ggdb -Wall -fPIC -std=c11 -dynamiclib  c_src/dpiConn_nif.c c_src/dpiContext_nif.c c_src/dpiData_nif.c c_src/dpiQueryInfo_nif.c c_src/dpiStmt_nif.c c_src/dpiVar_nif.c c_src/dpi_nif.c -Lc_src/odpi/lib -shared -lodpic -flat_namespace -undefined suppress
c_src/dpiData_nif.c:187:39: warning: incompatible pointer types passing 'int64_t *' (aka 'long long *') to parameter of type 'long *' [-Wincompatible-pointer-types]
    if (!enif_get_int64(env, argv[1], &amount))
                                      ^~~~~~~
/Users/agustin/kerl/20.2/erts-9.2/include/erl_nif_api_funcs.h:104:79: note: passing argument to parameter 'ip' here
ERL_NIF_API_FUNC_DECL(int,enif_get_long,(ErlNifEnv*, ERL_NIF_TERM term, long* ip));
                                                                              ^
1 warning generated.

It seems ERL_NIF_TERM enif_make_int64(ErlNifEnv* env, ErlNifSInt64 i) is internally mapped to enif_get_long(ErlNifEnv*, ERL_NIF_TERM term, long* ip) where (long *) != (int64_t *) (in Mac). Unfortunately ErlNifSInt64 isn't public (not with the current Erlang version anyway).

Perhaps I can't fix this one yet, have to wait for erlang version upgrade and revisit. @acautin Can you please create this into a issue?

and if there aren't anything else, please approve too

c-bik commented 5 years ago

@acautin and @KarlKeiser resolved some merge conflicts with master, can you please test?