BSIM plugins with MINGW

View: New views
4 Messages — Rating Filter:   Alert me  

BSIM plugins with MINGW

by Holger Vogt :: Rate this Message:

| View Threaded | Show Only this Message

Hi all,

after some discussions in 2007 there was no further mention of plugins
made with mingw. So I am not aware of any solution to the build
problems. Using the actual 6/11/09 gnucap snapshot, gnucap compiled "out
of the box" with mingw, but making the plugins failed immediately.

I have made the mingw BSIM plugins using a strange step by step
approach, not production worthy, but giving hints to what needs to be
done further. I am using gcc345 and msys1.0.

This is a continuation of the thread
[Gnucap-devel] Re: [Help-gnucap] plugins mingw compatibility
http://lists.gnu.org/archive/html/gnucap-devel/2007-04/msg00003.html
from Wed, 4 Apr 2007.

Making a dll requires that no unresolved symbols are there inside the
dll code, otherwise linking will fail. This is a much more stringent
requirement compared with making a *.so.

So my procedure is based on the ideas in
http://lists.gnu.org/archive/html/gnucap-devel/2007-11/msg00020.html

We need to export the symbols from gnucap.exe back to the dlls (via the
symbol table libgnucap2.a).

Exporting the symbol of the global variable nstat from gnucap.exe
however did not work, so I added a function
INTERFACE LOGIC_NODE* get_nstat() which will be exported and used by
spice-wrapper.cc to get the value of nstat. Still there was a dependency
problem with nstat inside the gnucap code during linking the dlls, which
I removed by "brute force" (not knowing if this has any adverse influence).

Perhaps it might be better to put all symbols (function addresses)
required by spice-wrapper.cc into a struct of function pointers, and
hand this struct over from gnucap.exe to the dll during attaching the dll.

If these problems have been already solved, please let me know.


Regards

Holger





So this is what I did:

spice-wrapper.cc:87 and others
FLOAT --> NFLOAT

spice-wrapper.cc:909-910
  LOGIC_NODE* nodestat = get_nstat();
  if (!nodestat) {


globals.h:25
#include "md.h"
globals.h:43-44
extern LOGIC_NODE* nstat;
extern INTERFACE LOGIC_NODE* get_nstat();

e_node.cc:31
INTERFACE LOGIC_NODE* get_nstat(); //hv

e_node.cc:588-591
INTERFACE LOGIC_NODE* get_nstat() //hv
{
    return nstat;
};

m_expression.h:114
class INTERFACE Expression

D:\gnucap\gnucap-2009-06-11\src\md.h:130
#undef INTERFACE

D:\gnucap\gnucap-2009-06-11\modelgen\md.h:130
#undef INTERFACE



edit make2 in D:\gnucap\gnucap-2009-06-11\models-bsim\Make2 (based on
make2.mingw):

PREFIX=/d/software/gnucap
GNUCAP_INCLUDE = ../../src
CC = gcc
CCC = g++
LDFLAGS = -shared -L$(GNUCAP_INCLUDE)
LIBS = -lgnucap2
    $(CCC) $(LDFLAGS) $(OBJS) $(LIBS) -o $(TARGET)$(SO_EXTENSION)  2>&1
| c++filt


prepare gnucap:
$ cd d:/gnucap/gnucap-2009-06-11
$ ./configure --prefix=/d/software/gnucap

make gnucap:
$ cd d:/gnucap/gnucap-2009-06-11
$ make

make dlls:
$ cd d:/gnucap/gnucap-2009-06-11/src
$ ar cru  libgnucap.a *.o
$ ar -s  libgnucap.a
$ dlltool -l libgnucap2.a -D gnucap.exe libgnucap.a
$ cd d:/gnucap/gnucap-2009-06-11/models-bsim
$ make clean
$ make

Resulting error message:
make[1]: Entering directory
`/d/gnucap/gnucap-2009-06-11/models-bsim/BSIM3v31'
g++ -shared -L../../src spice-wrapper.o b3acld.o b3cvtest.o b3del.o
b3dest.o b3getic.o b3ld.o b3mask.o b3mdel.o b3mpar.o b3par.o b3pzld.o
b3set.o b3temp.o b3trunc.o b3.o b3ask.o b3noi.o b3check.o  devsup.o
-lgnucap2 -o bsim310.dll  2>&1 | c++filt
spice-wrapper.o: In function `ZN9DEV_SPICE7ac_loadEv':
d:/gnucap/gnucap-2009-06-11/models-bsim/BSIM3v31/../../src/e_node.h:299:
undefined reference to `nstat'
collect2: ld returned 1 exit status
echo bsim310 done
bsim310 done


avoid error message during making the dlls (brute force)
e_node.h: 297
extern LOGIC_NODE* nstat; --> LOGIC_NODE* nstat = NULL;
make gnucap
make dlls


BSIM420 to BSIM463: compilation of b4set.c fails with
gcc -O2 -g -I. -I../Include -DTRACE_UNTESTED -DSPICE_3f -DPREDICTOR
-DHAS_STDLIB
-DMAKE_DLL -c b4set.c
In file included from ../Include/ftedata.h:12,
                 from ../Include/fteparse.h:15,
                 from ../Include/ftedefs.h:16,
                 from b4set.c:27:
../Include/cpstd.h:35: error: redefinition of `struct _complex'
make[1]: *** [b4set.o] Error 1

_complex is nowhere used in gnucap (but complex is):

cpstd.h:35
struct _complex --> struct _complex1

struct _complex1 {
    double cx_real;
    double cx_imag;
} ;

typedef struct _complex1 complex;

#define realpart(cval)  ((struct _complex1 *) (cval))->cx_real
#define imagpart(cval)  ((struct _complex1 *) (cval))->cx_imag
 
 

return to original code in e_node.h
make gnucap

copy gnucap.exe and b*.dll into /bin directory, load a plugin model and
start simulation.



_______________________________________________
Gnucap-devel mailing list
Gnucap-devel@...
http://lists.gnu.org/mailman/listinfo/gnucap-devel

Re: BSIM plugins with MINGW

by al davis-13 :: Rate this Message:

| View Threaded | Show Only this Message

On Monday 20 July 2009, Holger Vogt wrote:
> Using the actual 6/11/09 gnucap snapshot, gnucap compiled
> "out of the box" with mingw, but making the plugins failed
> immediately.

Thanks for the info.  I have applied your patches.  (or a variant).  
Try it now.

It compiles with mingw as a cross-compiler.  I don't have a way to
test beyond that.

I recommend the old (development) build system (./configure.old)  
You probably need to edit the "Make2" file ..  Use "Make2.mingw"
as your starting point.  You may also need to manually set up the
symlink for gnucap-modelgen.  Make2.mingw sets up the extra
files you need for DLL's.

Some spice models still fail.  They fail on Linux too.  
The status is documented in the README files.

http://www.gnucap.org/devel/gnucap-2009-07-21-models-bsim.tar.gz
http://www.gnucap.org/devel/gnucap-2009-07-21-models-jspice3-2.5.tar.gz
http://www.gnucap.org/devel/gnucap-2009-07-21-models-ngspice17.tar.gz
http://www.gnucap.org/devel/gnucap-2009-07-21-models-spice3f5.tar.gz
http://www.gnucap.org/devel/gnucap-2009-07-21-tools.tar.gz
http://www.gnucap.org/devel/gnucap-2009-07-21.md5sum
http://www.gnucap.org/devel/gnucap-2009-07-21.tar.gz



_______________________________________________
Gnucap-devel mailing list
Gnucap-devel@...
http://lists.gnu.org/mailman/listinfo/gnucap-devel

Re: BSIM plugins with MINGW

by al davis-13 :: Rate this Message:

| View Threaded | Show Only this Message

On Wednesday 22 July 2009, al davis wrote:
> It compiles with mingw as a cross-compiler.  I don't have a
> way to test beyond that.

It works on wine!

To cross compile ..

(Use the old build system.)
./configure.old
make
(builds a native version, you can stop it after it builds
modelgen)
cd src
make mingw
(builds the windows version)
(it's "gnucap.exe" in MSW)

untar a models package ..
cd models---------
rm Make2
ln -s Make2.mingw Make2
make
(builds the MS version of the plugins)
(some don't work .. I know)
(the *.dll files are plugins.  load as with unix)


The differences compared to  posix version ...
1. extension ".dll" instead of ".so"
2. Unresolved symbols in plugins are reported at compile time
for the MS version, vs at load time for the posix version.
3. You need to fix the "Make2" symlink. (or copy)
4. To cross compile, you need to make the "gnucap-modelgen"
symlink. (or copy)




_______________________________________________
Gnucap-devel mailing list
Gnucap-devel@...
http://lists.gnu.org/mailman/listinfo/gnucap-devel

Re: BSIM plugins with MINGW

by Holger Vogt :: Rate this Message:

| View Threaded | Show Only this Message

Hi all,

it works with plain mingw (gcc345) and Windows XP, using the old build
system and snapshot gnucap-2009-07-21:

cd /gnucap-2009-07-21

./configure.old
make

stop it after it builds modelgen
copy modelgen.exe from /gnucap-2009-07-21/modelgen
to /gnucap-2009-07-21/src/MSW

cd src

edit Make2.mingw32:
old:
CCC = i586-mingw32msvc-g++
DLLTOOL = i586-mingw32msvc-dlltool
new:
CCC = g++
DLLTOOL = dlltool

make mingw

yields "gnucap.exe" in MSW
yields libgnucap.a in MSW

untar a models package (e.g. models-bsim) to
/gnucap-2009-07-21/models-bsim

cd models-bsim

edit Make2.mingw32:
old:
GNUCAP_INCLUDE = ../Gnucap
CCC = i586-mingw32msvc-g++
DLLTOOL = i586-mingw32msvc-dlltool
new:
GNUCAP_INCLUDE = ../../src
CCC = g++
DLLTOOL = dlltool
 
copy Make2.mingw32 to Make2

make



Regards

Holger




_______________________________________________
Gnucap-devel mailing list
Gnucap-devel@...
http://lists.gnu.org/mailman/listinfo/gnucap-devel