Menu

#735 msys2's compiled ngspice doesn't find the path of some includes on paths

v1.0 (example)
closed-invalid
None
5
2025-04-12
2025-02-02
kreijstal
No

https://github.com/msys2/MINGW-packages/issues/23274

Basically when running this same code under mingw's ngspice it fails to find the path, why? In linux it works.

Thank you.

Discussion

1 2 > >> (Page 1 of 2)
  • kreijstal

    kreijstal - 2025-02-02

    code to reproduce:

    cat > test.spice <<'EOF'
    .title Voltage Multiplier
    
    * Include SkyWater sky130 device models
    *.lib "./sky130A/libs.tech/ngspice/sky130.lib.spice"
    .include "./sky130A/libs.tech/ngspice/corners/tt.spice"
    .param mc_mm_switch=0
    Vdd vdd gnd DC 1.8
    V1 in gnd pulse(0 1.8 0p 200p 100p 1n 2n)
    
    Xnot1 in vdd gnd out not1
    
    .subckt not1 a vdd vss z
    xm01   z a     vdd     vdd sky130_fd_pr__pfet_01v8_hvt  l=0.15  w=0.99  as=0.26235  ad=0.26235  ps=2.51   pd=2.51
    xm02   z a     vss     vss sky130_fd_pr__nfet_01v8  l=0.15  w=0.495 as=0.131175 ad=0.131175 ps=1.52   pd=1.52
    c3  a     vss   0.384f
    c2  z     vss   0.576f
    .ends
    
    
    * simulation command:
    .tran 1ps 10ns 0 10p
    
    .control
    run
    *set nolegend
    plot in out
    *rusage all
    .endc
    
    .end
    EOF
    
    wget "https://github.com/efabless/volare/releases/download/sky130-fa87f8f4bbcc7255b6f0c0fb506960f531ae2392/sky130_fd_pr.tar.zst"
    wget "https://github.com/efabless/volare/releases/download/sky130-fa87f8f4bbcc7255b6f0c0fb506960f531ae2392/common.tar.zst"
    tar -xvf common.tar.zst
    tar -xvf sky130_fd_pr.tar.zst
    ngspice_con.exe
    

    then type

    source test.spice
    
     
  • Dietmar Warning

    Dietmar Warning - 2025-02-03

    Don't know, but for me it works with a msys2/ucrt64 created exe from latest dev branch pre-master-45 tested in cmd environment (not bash). Same for ngspice_con.exe - w/o graphics.

    Sorry - Screenshot upload seems not functional.

     
  • kreijstal

    kreijstal - 2025-02-03

    hmm alright yes thank you, it seems ucrt64 works but mingw64 doesn't

     
  • kreijstal

    kreijstal - 2025-02-03

    nevermind, I spoke too fast, it happens with ucrt64 on windows 10 as well, but not with windows 11 on the distro default, I'm using ngspice_con

     
  • Dietmar Warning

    Dietmar Warning - 2025-02-03

    Oh, forgot to say: my check was under win 11.

     
  • Holger Vogt

    Holger Vogt - 2025-02-03

    You are using a relative path to find the models. Relative to what?

    On windows such calls are relative to the "current directory". This directory is typically the directory of the calling program, here ngspice_con.exe.

    If you want to use a different "current directory" when using ngspice, you may add a command
    cd new_current_dir
    into .spiceinit.

     
  • Giles Atkinson

    Giles Atkinson - 2025-02-03

    We are not told the ngspice version number, nor shown the complete output. A more adequate error report would be a big help.

    But this looks like a failure to splice the directory path of an included file to a relative .include file name that it contains. If so, the version must be 43 or 44, as that function did not exist before commit b660e75S. My guess is that inp_pathresolve_at() is failing to splice paths containing a mix of directory separators. It may be necessary to reproduce with a build with extra debugging.

    But for now, what is the file containing the failed path name? What is the ngspice version, the origin of the program (built locally, packaged), the Windows version, the default directory? All this background information should be in any bug report.

     
  • kreijstal

    kreijstal - 2025-02-03

    You are using a relative path to find the models. Relative to what?
    On windows such calls are relative to the "current directory". This directory is typically the directory of the calling program, here ngspice_con.exe.
    If you want to use a different "current directory" when using ngspice, you may add a command
    cd new_current_dir
    into .spiceinit.

    I gave a script, the script is meant to be executed on that directory, which works in linux, windows 11 but not winsows 10, ngspice_con runs exactly on that directory, the same process works on windows11 while the exact same process doesn't run on windows 10, I don't see how are paths relevant now. (provided it does work on windows 11 (and the msys2 version is the same))

    We are not told the ngspice version number

    The one compiled on msys2. https://packages.msys2.org/packages/mingw-w64-x86_64-ngspice PKGBUILD : https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-ngspice/PKGBUILD You can see the compilation flags here.

    For the one on linux I simply used the one that comes with archlinux: https://archlinux.org/packages/extra/x86_64/ngspice/

    Not sure if it is related but I'll try to compile ngspice-44 to see if the bug dissapears: there are some bugs:

    kreijstal@windows UCRT64 ~/git/MINGW-packages/mingw-w64-ngspice/src/build-shared-UCRT64/src/xspice/verilog
    # echo "  CC      " ivlng_la-icarus_shim.lo;/bin/sh ../../../libtool --silent --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H   -I. -I../../../../ngspice-44/src/xspice/verilog -I../../../src/include  -I../../../../src/include -march=nocona -msahf -mtune=generic -O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong -Wp,-D__USE_MINGW_ANSI_STDIO=1 -std=gnu11 -fopenmp -MT ivlng_la-icarus_shim.lo -MD -MP -MF .deps/ivlng_la-icarus_shim.Tpo -c -o ivlng_la-icarus_shim.lo `test -f 'icarus_shim.c' || echo '../../../../ngspice-44/src/xspice/verilog/'`icarus_shim.c
      CC       ivlng_la-icarus_shim.lo
    ../../../../ngspice-44/src/xspice/verilog/icarus_shim.c:21:10: fatal error: ngspice/cmtypes.h: No such file or directory
       21 | #include "ngspice/cmtypes.h" // For Digital_t
          |          ^~~~~~~~~~~~~~~~~~~
    compilation terminated.
    

    I simply took the PKGBUILD and replaced 42 with 44. However this might just be a packaging issue unrelated to the ngspice project. I'll try to get 44 version working on windows 10, but again as I said the bug does not occur with windows 11, only with windows 10.

     

    Last edit: kreijstal 2025-02-03
  • Holger Vogt

    Holger Vogt - 2025-02-03

    Use the current version of ngspice tagged ngspice-44.2 to get rid of the above error and some other bugs.

     

    Last edit: Holger Vogt 2025-02-03
  • kreijstal

    kreijstal - 2025-02-03

    @h_vogt Hmm interesting it seems it is failing here building ngspice_con

    ../../../ngspice-44.2/src/frontend/terminal.c:26:10: fatal error: curses.h: No such file or directory
       26 | #include <curses.h>
          |          ^~~~~~~~~~
    

    despite ncurses being installed.

    I wonder if this is a configure.ac bug?
    Here is a bit of the configure output attached.

     
  • Holger Vogt

    Holger Vogt - 2025-02-03

    Your configure log is the same as mine.

    configure.ac does not check for the curses.h header.

    What path does your curses.h have, where is it located?

     

    Last edit: Holger Vogt 2025-02-03
  • kreijstal

    kreijstal - 2025-02-03

    it is /ucrt64/include/ncurses/curses.h

    I patched it in configure.ac

    # git diff
    diff --git a/configure.ac b/configure.ac
    index f97a93ea6..21efa6973 100644
    --- a/configure.ac
    +++ b/configure.ac
    @@ -1280,6 +1280,18 @@ else
                     AC_CHECK_LIB([readline], [readline],
                         [LIBS="$LIBS -lreadline"],
                         [AC_MSG_ERROR([Couldn't find readline libraries.])])
    +
    
    +               PKG_CHECK_MODULES([NCURSES], [ncursesw], [
    +                       AC_SUBST([CURSES_CFLAGS], ["$NCURSES_CFLAGS"])
    +                       AC_SUBST([CURSES_LIBS], ["$NCURSES_LIBS"])
    +                       AC_DEFINE([HAVE_CURSES_H], [1], [Define if curses.h is available])
    +                       CPPFLAGS="$CPPFLAGS $NCURSES_CFLAGS"
    +               ])
    +               # Now check for curses.h using the updated CPPFLAGS
    +               AC_CHECK_HEADERS([curses.h], [], [
    +                   AC_MSG_WARN([curses.h not found.])
    +               ])
    +
                 fi
             else
         # Especially defined for macOS (Big Sur), with readline installed from Brew
    

    I tried the git master version, it seems it worked, not done with the compilation yet. I'll keep you updated.

     
  • kreijstal

    kreijstal - 2025-02-03

    Hmm something went terribly wrong

    CC="ccache gcc" LDFLAGS+=" -lgdi32" ../configure --disable-debug --enable-openmp --enable-xspice --enable-cider
    

    It seems /usr/ was prioritized and it took cygwin libraries instead... huh

    kreijstal@windows11 UCRT64 ~/git/ngspice-ngspice/build
    # ./src/ngspice.exe
          0 [main] ngspice (6124) child_copy: cygheap read copy failed, 0x800000000..0x800036F38, done 0, windows pid 6124, Win32 error 6
    
    kreijstal@windows11 UCRT64 ~/git/ngspice-ngspice/build
    # ntldd ./src/ngspice.exe
            ADVAPI32.dll => C:\Windows\SYSTEM32\ADVAPI32.dll (0x00000178a82f0000)
            libfftw3-3.dll => E:\msys64\ucrt64\bin\libfftw3-3.dll (0x00000178a82f0000)
            libgomp-1.dll => E:\msys64\ucrt64\bin\libgomp-1.dll (0x00000178a82f0000)
            KERNEL32.dll => C:\Windows\SYSTEM32\KERNEL32.dll (0x00000178a83b0000)
            SHELL32.dll => C:\Windows\SYSTEM32\SHELL32.dll (0x00000178a9150000)
            SHLWAPI.dll => C:\Windows\SYSTEM32\SHLWAPI.dll (0x00000178a8740000)
            libstdc++-6.dll => E:\msys64\ucrt64\bin\libstdc++-6.dll (0x00000178a8a40000)
            USER32.dll => C:\Windows\SYSTEM32\USER32.dll (0x00000178a8d90000)
            msys-ncursesw6.dll => E:\msys64\usr\bin\msys-ncursesw6.dll (0x00000178a8740000)
            msys-readline8.dll => E:\msys64\usr\bin\msys-readline8.dll (0x00000178a82f0000)
    
     

    Last edit: kreijstal 2025-02-03
  • kreijstal

    kreijstal - 2025-02-03

    there is a rogue -L/usr/lib that uses cygwin -lreadline -L/usr/lib -lpsapi -lshlwapi -fopenmp this breaks msys2

     
  • Holger Vogt

    Holger Vogt - 2025-02-04

    I prefer a strict separation between MINGW and Cygwin.

    Therefore I have installed MSYS2 seperately in addition to Cygwin, and I do not see any cross contamination. Compiling is done by a modified script in a MSYS2 bash window using compile_min.sh, by changing
    --with-wingui to --with-wingui=no
    with a resulting configure
    ../configure --with-wingui=no --enable-cider prefix="C:/Spice64d" CFLAGS="-g -m64 -O0 -Wall -Wno-unused-but-set-variable" LDFLAGS="-g -m64"

    Readline, OpenMP, XSPICE are included automatically.

    The ncurses problems remains however, caused by some update in MINGW.

    I'd propose to (temporarly) exclude the terminal code in terminal.c for a MINGW build by adding

    /* temporarily exclude code from compiling with MINGW */
    #ifdef __MINGW32__
    #undef HAVE_TERMCAP
    #endif
    

    to terminal.c.

    Compiling of pre-master-45 is successful then, however there remains a problem with installing ivlng.vpi as

    make  install-exec-hook
    make[5]: Entering directory '/d/Spice_general/ngspice-master/release/src/xspice/verilog'
    cd C:/Spice64/lib/ngspice; \
    rm -f ivlng*a libvvp* ; \
    mv ivlngvpi.* ivlng.vpi
    mv: cannot stat 'ivlngvpi.*': No such file or directory
    make[5]: *** [Makefile:849: install-exec-hook] Error 1
    

    Giles might have a look at this, as now MINGW is compiling.

    Generally I prefer Visual Studio 22, as compiling ngspice with VS needs 1min, compiling with MINGW 15min on my machine.

     

    Last edit: Holger Vogt 2025-02-04
    • kreijstal

      kreijstal - 2025-02-04

      I solved the problem by just adding --without-x It compiles and runs.

      No need to patch the code. (I just had some X libraries in my msys) (Not standard)

       

      Last edit: Holger Vogt 2025-02-04
    • Giles Atkinson

      Giles Atkinson - 2025-02-04

      Holger,

      This error occurs because libtool fails to build the Icarus support DLLs, but treats it as a warning, so the error appears at the install stage. The failure is connected to configure's liking for ncurses, which is actually not used. I am testing fixes.

      Giles

       
      • Holger Vogt

        Holger Vogt - 2025-02-04

        looking for ncursesw instead of ncurses seems to help (MINGW mingw64). See git branch hv_curses.

         

        Last edit: Holger Vogt 2025-02-04
    • kreijstal

      kreijstal - 2025-02-04

      I think the slowdown of mingw compilation comes from autotools, not from mingw, does visual studio compilation doesn't use autotools, maybe cmake would be comparable. I wouldn't know.

       
      • Holger Vogt

        Holger Vogt - 2025-02-04

        On Linux the compilation with the ngspice Autotools takes between 1 and 1.5min.

         
  • Holger Vogt

    Holger Vogt - 2025-02-04

    Compiling and linking a console ngspice with ncurses on MINGW is possible by some code changes to terminal.c and configure.ac, as shown in ngspice git branch hv_curses.

    I don't think however that this is wothwhile persuing, as tests have to be done on all relevant operating systems, and distribution would require additional dlls.

     
  • kreijstal

    kreijstal - 2025-02-04

    Anyway, I finally compiled ngspice 44.2 and now I get the following error message: under windows 10

    Error: Could not find include file ../../../libs.tech/ngspice/parasitics/sky130_fd_pr__model__parasitic__diode_pw2dn__extended_drain.model.spice
        While reading .\sky130/sky130A/libs.tech/ngspice/corners\../../../libs.ref/sky130_fd_pr/spice\sky130_fd_pr__nfet_20v0__subcircuit.pm3.spice
    
    ERROR: fatal error in ngspice, exit(1)
    

    when sourcing test.spice

    Edit:

    now I tried with windows11, and it works without problems:

    # ngspice_con.exe
    ******
    ** ngspice-44.2 : Circuit level simulation program
    ** Compiled with KLU Direct Linear Solver
    ** The U. C. Berkeley CAD Group
    ** Copyright 1985-1994, Regents of the University of California.                                                                                                                                                                                       ** Copyright 2001-2024, The ngspice team.
    ** Please get your ngspice manual from https://ngspice.sourceforge.io/docs.html
    ** Please file your bug-reports at http://ngspice.sourceforge.net/bugrep.html
    ** Creation Date: Tue Feb  4 16:11:16 UTC 2025
    ******
    Warning: no graphics interface!
     You may use command 'gnuplot'
     if GnuPlot is installed.
    ngspice 1 -> source test.spice
                                                                                                                                                                                                                                                           Note: No compatibility mode selected!
    
                                                                                                                                                                                                                                                           Circuit: Voltage Multiplier
                                                                                                                                                                                                                                                           Doing analysis at TEMP = 27.000000 and TNOM = 27.000000
    
    Using SPARSE 1.3 as Direct Linear Solver
    
    Initial Transient Solution
    --------------------------
    
    Node                                   Voltage
    ----                                   -------                                                                                                                                                                                                         vdd                                        1.8
    in                                           0
    out                                        1.8
    v1#branch                                    0
    vdd#branch                        -1.90256e-12
    
     Reference value :  0.00000e+00                                                                                                                                                                                                                        No. of Data Rows : 1068
    Can't open viewport for graphics.
    ngspice 2 ->
    

    I can test the latest git version if you want, but I don't believe it will give me a different result

     

    Last edit: kreijstal 2025-02-04
  • Holger Vogt

    Holger Vogt - 2025-02-04

    I have been using ngspice-44+, console as well as GUI, both MINGW and VS, Windows 10, sourcing your input file, using an absolute path to the Skywater library: no problem at all to run the simulation.

    You might use an absolute path as well. And check your Skywater library install.

     

    Last edit: Holger Vogt 2025-02-04
    • kreijstal

      kreijstal - 2025-02-04

      I don't have a problem either on windows 11, however on windows 10, I do. Does it work for you as well on windows 10? My problem only happens on windows 10.

      I'll try an absolute path, I think I did, and it didn't work either. I'll try outside the msys2 enviroment, to see if it is related to that.

      Edit: Wow, ok, I'll see what's going on, thank you for the feedback.

       

      Last edit: kreijstal 2025-02-04
1 2 > >> (Page 1 of 2)

Log in to post a comment.

MongoDB Logo MongoDB