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

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

[Octave-bug-tracker] [bug #55363] Global variable in a MEX file


From: Guillaume
Subject: [Octave-bug-tracker] [bug #55363] Global variable in a MEX file
Date: Wed, 2 Jan 2019 08:02:33 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0

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

                 Summary: Global variable in a MEX file
                 Project: GNU Octave
            Submitted by: gyom
            Submitted on: Wed 02 Jan 2019 01:02:32 PM UTC
                Category: Configuration and Build System
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: Guillaume
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: dev
        Operating System: GNU/Linux

    _______________________________________________________

Details:

I notice a difference in behavior concerning global variables defined in MEX
files between Matlab or Octave (openSUSE 15.0, gcc 7.3.1) on one side and
Octave (Ubuntu 18.10, gcc 8.2.0) on the other side.

Using the two attached files after compilation, on Matlab or Octave 4.4.0
(openSUSE 15.0, gcc 7.3.1), one gets:


octave:1> mytest1
myglobalvar = 1
octave:2> mytest2
myglobalvar = 2
octave:3> mytest2 (3)
octave:4> mytest2
myglobalvar = 3
octave:5> mytest1
myglobalvar = 1


while on Octave 4.4.1 (Ubuntu 18.10, gcc 8.2.0), one gets:


octave:1> mytest1
myglobalvar = 1
octave:2> mytest2
myglobalvar = 1
octave:3> mytest2 (3)
octave:4> mytest2
myglobalvar = 3
octave:5> mytest1
myglobalvar = 3


This seems to indicate that globally defined variables are not exported from
the (MEX) shared library with Matlab (ie behave as static) while this does not
seem to be the case on the Ubuntu platform.

The compilation flags on the two platforms are copied below.

On OpenSUSE 15.0, gcc 7.3.1:


> mkoctfile --mex -v mytest1.c
gcc -c -DH5_USE_16_API -fPIC -I/usr/include/octave-4.4.0/octave/..
-I/usr/include/octave-4.4.0/octave  -pthread -fopenmp -fmessage-length=0
-grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong
-funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g   -I.
 -DMEX_DEBUG mytest1.c -o mytest1.o
g++ -I/usr/include/octave-4.4.0/octave/.. -I/usr/include/octave-4.4.0/octave 
-pthread -fopenmp -fmessage-length=0 -grecord-gcc-switches -O2 -Wall
-D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables
-fasynchronous-unwind-tables -fstack-clash-protection -g -shared
-Wl,-Bsymbolic  -o mytest1.mex  mytest1.o   -L/usr/lib64/octave/4.4.0
-L/usr/lib64 -loctinterp -loctave


On Ubuntu 18.10, gcc 8.2.0:


# mkoctfile --mex -v mytest1.c
gcc -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC
-I/usr/include/octave-4.4.1/octave/.. -I/usr/include/octave-4.4.1/octave 
-pthread -fopenmp -g -O2
-fdebug-prefix-map=/build/octave-ulduBN/octave-4.4.1=.
-fstack-protector-strong -Wformat -Werror=format-security   -I.  -DMEX_DEBUG
mytest1.c -o mytest1.o
g++ -I/usr/include/octave-4.4.1/octave/.. -I/usr/include/octave-4.4.1/octave 
-pthread -fopenmp -g -O2
-fdebug-prefix-map=/build/octave-ulduBN/octave-4.4.1=.
-fstack-protector-strong -Wformat -Werror=format-security -shared
-Wl,-Bsymbolic  -o mytest1.mex  mytest1.o  
-L/usr/lib/x86_64-linux-gnu/octave/4.4.1 -L/usr/lib/x86_64-linux-gnu
-loctinterp -loctave -Wl,-Bsymbolic-functions -Wl,-z,relro 




    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Wed 02 Jan 2019 01:02:32 PM UTC  Name: mytest1.c  Size: 239B   By: gyom

<http://savannah.gnu.org/bugs/download.php?file_id=45840>
-------------------------------------------------------
Date: Wed 02 Jan 2019 01:02:32 PM UTC  Name: mytest2.c  Size: 239B   By: gyom

<http://savannah.gnu.org/bugs/download.php?file_id=45841>

    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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