octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #54804] mex.m does not support setting flags i


From: Richard
Subject: [Octave-bug-tracker] [bug #54804] mex.m does not support setting flags in the same manner as the Matlab implementation
Date: Mon, 8 Oct 2018 05:50:24 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0

URL:
  <https://savannah.gnu.org/bugs/?54804>

                 Summary: mex.m does not support setting flags in the same
manner as the Matlab implementation
                 Project: GNU Octave
            Submitted by: crobar
            Submitted on: Mon 08 Oct 2018 09:50:22 AM UTC
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Matlab Compatibility
                  Status: None
             Assigned to: None
         Originator Name: Richard Crozier
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 4.4.1
        Operating System: Any

    _______________________________________________________

Details:

Matlab's implementation of mex supports setting compiler flags and many other
things by means of key-value pair arguments in the call to mex. This is not
supported by Octave's mex.m or mkoctfile.

On the main documentation for the mex function it states:

varname=varvalue

Overrides default setting for variable varname. This option is processed after
all command-line arguments are considered.

For more detailed documentation on this, see

https://uk.mathworks.com/help/matlab/ref/mex.html#btw193g-1

so, for example one can do:

mex -v CXXFLAGS='$CXXFLAGS -Wall' yprime.c

to append -Wall to the existing CXXFLAGS

The flags which can be modified include the usual culprits, CFLAGS, CXXFLAGS,
LDFLAGS, CC, LD, CXX etc, but depend on what is being compiled. For example,
for a C source file, the verbose output of mex produces the following (in
R2018a):


>> mex -v yprime.c
Verbose mode is on.
... Looking for compiler 'gcc' ...
... Executing command 'which gcc' ...Yes ('/usr/bin/gcc').
... Executing command 'gcc -print-file-name=libstdc++.so' ...Yes
('/usr/lib/gcc/x86_64-linux-gnu/7/libstdc++.so').
Found installed compiler 'gcc'.
Options file details
-------------------------------------------------------------------
        Compiler location: /usr/bin/gcc
        Options file: /home/rcrozier/.matlab/R2018a/mex_C_glnxa64.xml
        CMDLINE2 : /usr/bin/gcc -pthread -Wl,--no-undefined
-Wl,-rpath-link,/usr/local/MATLAB/R2018a/bin/glnxa64 -shared  -O
-Wl,--version-script,"/usr/local/MATLAB/R2018a/extern/lib/glnxa64/c_exportsmexfileversion.map"
/tmp/mex_16912733444478_15474/yprime.o
/tmp/mex_16912733444478_15474/c_mexapi_version.o  
-L"/usr/local/MATLAB/R2018a/bin/glnxa64" -lmx -lmex -lmat -lm -lstdc++ -o
yprime.mexa64
        CC : /usr/bin/gcc
        DEFINES : -DMATLAB_DEFAULT_RELEASE=R2017b  -DUSE_MEX_CMD   -D_GNU_SOURCE
-DMATLAB_MEX_FILE 
        MATLABMEX : -DMATLAB_MEX_FILE 
        CFLAGS : -fexceptions -fPIC -fno-omit-frame-pointer -pthread
        INCLUDE : -I"/usr/local/MATLAB/R2018a/extern/include"
-I"/usr/local/MATLAB/R2018a/simulink/include"
        COPTIMFLAGS : -O -DNDEBUG
        CDEBUGFLAGS : -g
        LD : /usr/bin/gcc
        LDFLAGS : -pthread -Wl,--no-undefined
-Wl,-rpath-link,/usr/local/MATLAB/R2018a/bin/glnxa64
        LDTYPE : -shared 
        FUNCTIONMAP : 
"/usr/local/MATLAB/R2018a/extern/lib/glnxa64/mexFunction.map"
        VERSIONMAP :
"/usr/local/MATLAB/R2018a/extern/lib/glnxa64/c_exportsmexfileversion.map"
        LINKEXPORT :
-Wl,--version-script,"/usr/local/MATLAB/R2018a/extern/lib/glnxa64/mexFunction.map"
        LINKEXPORTVER :
-Wl,--version-script,"/usr/local/MATLAB/R2018a/extern/lib/glnxa64/c_exportsmexfileversion.map"
        LINKLIBS : -L"/usr/local/MATLAB/R2018a/bin/glnxa64" -lmx -lmex -lmat -lm
-lstdc++
        LDOPTIMFLAGS : -O
        LDDEBUGFLAGS : -g
        MWCPPLIB : "/usr/local/MATLAB/R2018a/sys/os/glnxa64/libstdc++.so.6"
        OBJEXT : .o
        LDEXT : .mexa64
        SETENV : CC="/usr/bin/gcc"
                CXX="g++"
                CFLAGS="-fexceptions -fPIC -fno-omit-frame-pointer -pthread
-DMATLAB_DEFAULT_RELEASE=R2017b  -DUSE_MEX_CMD   -D_GNU_SOURCE
-DMATLAB_MEX_FILE "
                CXXFLAGS="-fexceptions -fPIC -fno-omit-frame-pointer -pthread
-std=c++11 -DMATLAB_DEFAULT_RELEASE=R2017b  -DUSE_MEX_CMD   -D_GNU_SOURCE
-DMATLAB_MEX_FILE "
                COPTIMFLAGS="-O -DNDEBUG"
                CXXOPTIMFLAGS="-O -DNDEBUG"
                CDEBUGFLAGS="-g"
                CXXDEBUGFLAGS="-g"
                LD="/usr/bin/gcc"
                LDXX="g++"
                LDFLAGS="-pthread -Wl,--no-undefined
-Wl,-rpath-link,/usr/local/MATLAB/R2018a/bin/glnxa64 -shared 
-L"/usr/local/MATLAB/R2018a/bin/glnxa64" -lmx -lmex -lmat -lm -lstdc++
-Wl,--version-script,"/usr/local/MATLAB/R2018a/extern/lib/glnxa64/mexFunction.map""
                LDDEBUGFLAGS="-g"
        GCC : /usr/bin/gcc
        CPPLIBS : /usr/lib/gcc/x86_64-linux-gnu/7/libstdc++.so
        MATLABROOT : /usr/local/MATLAB/R2018a
        ARCH : glnxa64
        SRC :
"/home/rcrozier/src/rnfoundry-hg/yprime.c";"/usr/local/MATLAB/R2018a/extern/version/c_mexapi_version.c"
        OBJ :
/tmp/mex_16912733444478_15474/yprime.o;/tmp/mex_16912733444478_15474/c_mexapi_version.o
        OBJS : /tmp/mex_16912733444478_15474/yprime.o
/tmp/mex_16912733444478_15474/c_mexapi_version.o 
        SRCROOT : /home/rcrozier/src/rnfoundry-hg/yprime
        DEF : /tmp/mex_16912733444478_15474/yprime.def
        EXP : "yprime.exp"
        LIB : "yprime.lib"
        EXE : yprime.mexa64
        ILK : "yprime.ilk"
        MANIFEST : "yprime.mexa64.manifest"
        TEMPNAME : yprime
        EXEDIR : 
        EXENAME : yprime
        OPTIM : -O -DNDEBUG
        LINKOPTIM : -O
        CMDLINE1_0 : /usr/bin/gcc -c -DMATLAB_DEFAULT_RELEASE=R2017b  
-DUSE_MEX_CMD  
-D_GNU_SOURCE -DMATLAB_MEX_FILE  -I"/usr/local/MATLAB/R2018a/extern/include"
-I"/usr/local/MATLAB/R2018a/simulink/include" -fexceptions -fPIC
-fno-omit-frame-pointer -pthread -O -DNDEBUG
"/home/rcrozier/src/rnfoundry-hg/yprime.c" -o
/tmp/mex_16912733444478_15474/yprime.o
        CMDLINE1_1 : /usr/bin/gcc -c -DMATLAB_DEFAULT_RELEASE=R2017b  
-DUSE_MEX_CMD  
-D_GNU_SOURCE -DMATLAB_MEX_FILE  -I"/usr/local/MATLAB/R2018a/extern/include"
-I"/usr/local/MATLAB/R2018a/simulink/include" -fexceptions -fPIC
-fno-omit-frame-pointer -pthread -O -DNDEBUG
"/usr/local/MATLAB/R2018a/extern/version/c_mexapi_version.c" -o
/tmp/mex_16912733444478_15474/c_mexapi_version.o
-------------------------------------------------------------------
Building with 'gcc'.
Warning: You are using gcc version '7.3.0'. The version of gcc is not
supported. The version currently supported with MEX is '6.3.x'. For a list of
currently
supported compilers see:
https://www.mathworks.com/support/compilers/current_release.
(Type "warning off MATLAB:mex:GccVersion_link" to suppress this warning.)
 
/usr/bin/gcc -c -DMATLAB_DEFAULT_RELEASE=R2017b  -DUSE_MEX_CMD   -D_GNU_SOURCE
-DMATLAB_MEX_FILE  -I"/usr/local/MATLAB/R2018a/extern/include"
-I"/usr/local/MATLAB/R2018a/simulink/include" -fexceptions -fPIC
-fno-omit-frame-pointer -pthread -O -DNDEBUG
"/home/rcrozier/src/rnfoundry-hg/yprime.c" -o
/tmp/mex_16912733444478_15474/yprime.o
/usr/bin/gcc -c -DMATLAB_DEFAULT_RELEASE=R2017b  -DUSE_MEX_CMD   -D_GNU_SOURCE
-DMATLAB_MEX_FILE  -I"/usr/local/MATLAB/R2018a/extern/include"
-I"/usr/local/MATLAB/R2018a/simulink/include" -fexceptions -fPIC
-fno-omit-frame-pointer -pthread -O -DNDEBUG
"/usr/local/MATLAB/R2018a/extern/version/c_mexapi_version.c" -o
/tmp/mex_16912733444478_15474/c_mexapi_version.o
/usr/bin/gcc -pthread -Wl,--no-undefined
-Wl,-rpath-link,/usr/local/MATLAB/R2018a/bin/glnxa64 -shared  -O
-Wl,--version-script,"/usr/local/MATLAB/R2018a/extern/lib/glnxa64/c_exportsmexfileversion.map"
/tmp/mex_16912733444478_15474/yprime.o
/tmp/mex_16912733444478_15474/c_mexapi_version.o  
-L"/usr/local/MATLAB/R2018a/bin/glnxa64" -lmx -lmex -lmat -lm -lstdc++ -o
yprime.mexa64
Recompile embedded version with '-DMATLAB_MEXCMD_RELEASE=R2017b'
/usr/bin/gcc -c -DMATLAB_DEFAULT_RELEASE=R2017b  -DUSE_MEX_CMD   -D_GNU_SOURCE
-DMATLAB_MEX_FILE  -I"/usr/local/MATLAB/R2018a/extern/include"
-I"/usr/local/MATLAB/R2018a/simulink/include" -fexceptions -fPIC
-fno-omit-frame-pointer -pthread -O -DNDEBUG
"/usr/local/MATLAB/R2018a/extern/version/c_mexapi_version.c" -o
/tmp/mex_16912733444478_15474/c_mexapi_version.o
-DMATLAB_MEXCMD_RELEASE=R2017b
/usr/bin/gcc -pthread -Wl,--no-undefined
-Wl,-rpath-link,/usr/local/MATLAB/R2018a/bin/glnxa64 -shared  -O
-Wl,--version-script,"/usr/local/MATLAB/R2018a/extern/lib/glnxa64/c_exportsmexfileversion.map"
/tmp/mex_16912733444478_15474/yprime.o
/tmp/mex_16912733444478_15474/c_mexapi_version.o  
-L"/usr/local/MATLAB/R2018a/bin/glnxa64" -lmx -lmex -lmat -lm -lstdc++ -o
yprime.mexa64
MEX completed successfully.


Basically every variable here can be modified using the key-value pairs
arguments, and it is really very useful to be able to do this. 

for a C++ source file I get the following


>> mex -v yprime.cpp
Verbose mode is on.
... Looking for compiler 'g++' ...
... Executing command 'which g++' ...Yes ('/usr/bin/g++').
... Executing command 'g++ -print-file-name=libstdc++.so' ...Yes
('/usr/lib/gcc/x86_64-linux-gnu/7/libstdc++.so').
... Executing command 'g++ -dumpversion' ...Yes ('7').
... Executing command 'which g++' ...Yes ('/usr/bin/g++').
... Looking for folder '/usr' ...Yes.
... Executing command 'g++ -dumpmachine' ...Yes ('x86_64-linux-gnu').
Found installed compiler 'g++'.
Set INCLUDE =
/usr/lib/gcc/x86_64-linux-gnu/7/include;/usr/include/c++/7;/usr/include/c++/7/x86_64-linux-gnu;/usr/include/c++/7/backward;
Options file details
-------------------------------------------------------------------
        Compiler location: /usr/bin/g++
        Options file: /home/rcrozier/.matlab/R2018a/mex_C++_glnxa64.xml
        CMDLINE2 : /usr/bin/g++ -pthread -Wl,--no-undefined  -shared -O
-Wl,--version-script,"/usr/local/MATLAB/R2018a/extern/lib/glnxa64/c_exportsmexfileversion.map"
/tmp/mex_17709496582947_15474/yprime.o
/tmp/mex_17709496582947_15474/cpp_mexapi_version.o   -Wl,--as-needed
-Wl,-rpath-link,/usr/local/MATLAB/R2018a/bin/glnxa64
-L"/usr/local/MATLAB/R2018a/bin/glnxa64"
-Wl,-rpath-link,/usr/local/MATLAB/R2018a/extern/bin/glnxa64
-L"/usr/local/MATLAB/R2018a/extern/bin/glnxa64" -lMatlabDataArray -lmx -lmex
-lmat -lm -lstdc++ -o yprime.mexa64
        CXX : /usr/bin/g++
        DEFINES : -DMATLAB_DEFAULT_RELEASE=R2017b  -DUSE_MEX_CMD   -D_GNU_SOURCE
-DMATLAB_MEX_FILE 
        MATLABMEX : -DMATLAB_MEX_FILE 
        CFLAGS : -fexceptions -fPIC -fno-omit-frame-pointer -pthread
        CXXFLAGS : -fexceptions -fPIC -fno-omit-frame-pointer -pthread 
-std=c++11
        INCLUDE : -I"/usr/local/MATLAB/R2018a/extern/include"
-I"/usr/local/MATLAB/R2018a/simulink/include"
        CXXOPTIMFLAGS : -O -DNDEBUG
        CXXDEBUGFLAGS : -g
        LDXX : /usr/bin/g++
        LDFLAGS : -pthread -Wl,--no-undefined 
        LDTYPE : -shared
        LINKEXPORT :
-Wl,--version-script,"/usr/local/MATLAB/R2018a/extern/lib/glnxa64/mexFunction.map"
        LINKEXPORTVER :
-Wl,--version-script,"/usr/local/MATLAB/R2018a/extern/lib/glnxa64/c_exportsmexfileversion.map"
        LINKLIBS : -Wl,--as-needed
-Wl,-rpath-link,/usr/local/MATLAB/R2018a/bin/glnxa64
-L"/usr/local/MATLAB/R2018a/bin/glnxa64"
-Wl,-rpath-link,/usr/local/MATLAB/R2018a/extern/bin/glnxa64
-L"/usr/local/MATLAB/R2018a/extern/bin/glnxa64" -lMatlabDataArray -lmx -lmex
-lmat -lm -lstdc++
        LDOPTIMFLAGS : -O
        LDDEBUGFLAGS : -g
        MWCPPLIB : "/usr/local/MATLAB/R2018a/sys/os/glnxa64/libstdc++.so.6"
        OBJEXT : .o
        LDEXT : .mexa64
        SETENV : CC="gcc"
                CXX="/usr/bin/g++"
                CFLAGS="-fexceptions -fPIC -fno-omit-frame-pointer -pthread
-DMATLAB_DEFAULT_RELEASE=R2017b  -DUSE_MEX_CMD   -D_GNU_SOURCE
-DMATLAB_MEX_FILE "
                CXXFLAGS="-fexceptions -fPIC -fno-omit-frame-pointer -pthread
-std=c++11 -DMATLAB_DEFAULT_RELEASE=R2017b  -DUSE_MEX_CMD   -D_GNU_SOURCE
-DMATLAB_MEX_FILE "
                COPTIMFLAGS="-O -DNDEBUG"
                CXXOPTIMFLAGS="-O -DNDEBUG"
                CDEBUGFLAGS="-g"
                CXXDEBUGFLAGS="-g"
                LD="gcc"
                LDXX="/usr/bin/g++"
                LDFLAGS="-pthread -Wl,--no-undefined  -shared -Wl,--as-needed
-Wl,-rpath-link,/usr/local/MATLAB/R2018a/bin/glnxa64
-L"/usr/local/MATLAB/R2018a/bin/glnxa64"
-Wl,-rpath-link,/usr/local/MATLAB/R2018a/extern/bin/glnxa64
-L"/usr/local/MATLAB/R2018a/extern/bin/glnxa64" -lMatlabDataArray -lmx -lmex
-lmat -lm -lstdc++
-Wl,--version-script,"/usr/local/MATLAB/R2018a/extern/lib/glnxa64/mexFunction.map""
                LDDEBUGFLAGS="-g"
        GCC : /usr/bin/g++
        CPPLIB_DIR : /usr/lib/gcc/x86_64-linux-gnu/7/libstdc++.so
        VER : 7
        GCCDIR : /usr
        GCC_TARGET : x86_64-linux-gnu
        MATLABROOT : /usr/local/MATLAB/R2018a
        ARCH : glnxa64
        SRC :
"/home/rcrozier/src/rnfoundry-hg/yprime.cpp";"/usr/local/MATLAB/R2018a/extern/version/cpp_mexapi_version.cpp"
        OBJ :
/tmp/mex_17709496582947_15474/yprime.o;/tmp/mex_17709496582947_15474/cpp_mexapi_version.o
        OBJS : /tmp/mex_17709496582947_15474/yprime.o
/tmp/mex_17709496582947_15474/cpp_mexapi_version.o 
        SRCROOT : /home/rcrozier/src/rnfoundry-hg/yprime
        DEF : /tmp/mex_17709496582947_15474/yprime.def
        EXP : "yprime.exp"
        LIB : "yprime.lib"
        EXE : yprime.mexa64
        ILK : "yprime.ilk"
        MANIFEST : "yprime.mexa64.manifest"
        TEMPNAME : yprime
        EXEDIR : 
        EXENAME : yprime
        OPTIM : -O -DNDEBUG
        LINKOPTIM : -O
        CMDLINE1_0 : /usr/bin/g++ -c -DMATLAB_DEFAULT_RELEASE=R2017b  
-DUSE_MEX_CMD  
-D_GNU_SOURCE -DMATLAB_MEX_FILE  -I"/usr/local/MATLAB/R2018a/extern/include"
-I"/usr/local/MATLAB/R2018a/simulink/include" -fexceptions -fPIC
-fno-omit-frame-pointer -pthread -std=c++11 -O -DNDEBUG
"/home/rcrozier/src/rnfoundry-hg/yprime.cpp" -o
/tmp/mex_17709496582947_15474/yprime.o
        CMDLINE1_1 : /usr/bin/g++ -c -DMATLAB_DEFAULT_RELEASE=R2017b  
-DUSE_MEX_CMD  
-D_GNU_SOURCE -DMATLAB_MEX_FILE  -I"/usr/local/MATLAB/R2018a/extern/include"
-I"/usr/local/MATLAB/R2018a/simulink/include" -fexceptions -fPIC
-fno-omit-frame-pointer -pthread -std=c++11 -O -DNDEBUG
"/usr/local/MATLAB/R2018a/extern/version/cpp_mexapi_version.cpp" -o
/tmp/mex_17709496582947_15474/cpp_mexapi_version.o
-------------------------------------------------------------------
Building with 'g++'.
Warning: You are using gcc version '7.3.0'. The version of gcc is not
supported. The version currently supported with MEX is '6.3.x'. For a list of
currently
supported compilers see:
https://www.mathworks.com/support/compilers/current_release.
(Type "warning off MATLAB:mex:GccVersion_link" to suppress this warning.)
 
/usr/bin/g++ -c -DMATLAB_DEFAULT_RELEASE=R2017b  -DUSE_MEX_CMD   -D_GNU_SOURCE
-DMATLAB_MEX_FILE  -I"/usr/local/MATLAB/R2018a/extern/include"
-I"/usr/local/MATLAB/R2018a/simulink/include" -fexceptions -fPIC
-fno-omit-frame-pointer -pthread -std=c++11 -O -DNDEBUG
"/home/rcrozier/src/rnfoundry-hg/yprime.cpp" -o
/tmp/mex_17709496582947_15474/yprime.o
/usr/bin/g++ -c -DMATLAB_DEFAULT_RELEASE=R2017b  -DUSE_MEX_CMD   -D_GNU_SOURCE
-DMATLAB_MEX_FILE  -I"/usr/local/MATLAB/R2018a/extern/include"
-I"/usr/local/MATLAB/R2018a/simulink/include" -fexceptions -fPIC
-fno-omit-frame-pointer -pthread -std=c++11 -O -DNDEBUG
"/usr/local/MATLAB/R2018a/extern/version/cpp_mexapi_version.cpp" -o
/tmp/mex_17709496582947_15474/cpp_mexapi_version.o
/usr/bin/g++ -pthread -Wl,--no-undefined  -shared -O
-Wl,--version-script,"/usr/local/MATLAB/R2018a/extern/lib/glnxa64/c_exportsmexfileversion.map"
/tmp/mex_17709496582947_15474/yprime.o
/tmp/mex_17709496582947_15474/cpp_mexapi_version.o   -Wl,--as-needed
-Wl,-rpath-link,/usr/local/MATLAB/R2018a/bin/glnxa64
-L"/usr/local/MATLAB/R2018a/bin/glnxa64"
-Wl,-rpath-link,/usr/local/MATLAB/R2018a/extern/bin/glnxa64
-L"/usr/local/MATLAB/R2018a/extern/bin/glnxa64" -lMatlabDataArray -lmx -lmex
-lmat -lm -lstdc++ -o yprime.mexa64
Recompile embedded version with '-DMATLAB_MEXCMD_RELEASE=R2017b'
/usr/bin/g++ -c -DMATLAB_DEFAULT_RELEASE=R2017b  -DUSE_MEX_CMD   -D_GNU_SOURCE
-DMATLAB_MEX_FILE  -I"/usr/local/MATLAB/R2018a/extern/include"
-I"/usr/local/MATLAB/R2018a/simulink/include" -fexceptions -fPIC
-fno-omit-frame-pointer -pthread -std=c++11 -O -DNDEBUG
"/usr/local/MATLAB/R2018a/extern/version/cpp_mexapi_version.cpp" -o
/tmp/mex_17709496582947_15474/cpp_mexapi_version.o
-DMATLAB_MEXCMD_RELEASE=R2017b
/usr/bin/g++ -pthread -Wl,--no-undefined  -shared -O
-Wl,--version-script,"/usr/local/MATLAB/R2018a/extern/lib/glnxa64/c_exportsmexfileversion.map"
/tmp/mex_17709496582947_15474/yprime.o
/tmp/mex_17709496582947_15474/cpp_mexapi_version.o   -Wl,--as-needed
-Wl,-rpath-link,/usr/local/MATLAB/R2018a/bin/glnxa64
-L"/usr/local/MATLAB/R2018a/bin/glnxa64"
-Wl,-rpath-link,/usr/local/MATLAB/R2018a/extern/bin/glnxa64
-L"/usr/local/MATLAB/R2018a/extern/bin/glnxa64" -lMatlabDataArray -lmx -lmex
-lmat -lm -lstdc++ -o yprime.mexa64
MEX completed successfully.







    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?54804>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]