Skip to content

Instantly share code, notes, and snippets.

@nauhygon
Last active March 25, 2021 21:09
Show Gist options
  • Save nauhygon/8ac1cdaada54fd5d920ce07944de18f5 to your computer and use it in GitHub Desktop.
Save nauhygon/8ac1cdaada54fd5d920ce07944de18f5 to your computer and use it in GitHub Desktop.
Steps to build Z3 and its Python bindings in MSYS2
  • Install x86_64-w64-mingw32 tools to build z3 & its Python bindings
  • Install mingw-w64-cross-binutils (to fix AR missing)
    • `pacman -S pacman -S mingw-w64-cross-binutils`
  • Explicitly add ‘.exe’ extension to CXX/CC/AR
    • and explicitly export them!
    • `export CXX=x86_64-w64-mingw32-g++.exe CC=x86_64-w64-mingw32-gcc.exe AR=x86_64-w64-mingw32-ar.exe`
  • Add /opt/bin to PATH
  • Force scripts/mk_util.py to recognize MSYS2
    diff --git a/scripts/mk_util.py b/scripts/mk_util.py
    index a8bdd4a8d..0f0692b41 100644
    --- a/scripts/mk_util.py
    +++ b/scripts/mk_util.py
    @@ -75,7 +75,8 @@ IS_OPENBSD=False
     IS_SUNOS=False
     IS_CYGWIN=False
     IS_CYGWIN_MINGW=False
    -IS_MSYS2=False
    +#IS_MSYS2=False
    +IS_MSYS2=True
     VERBOSE=True
     DEBUG_MODE=False
     SHOW_CPPS = True
    @@ -592,6 +593,12 @@ if os.name == 'nt':
         IS_WINDOWS=True
         # Visual Studio already displays the files being compiled
         SHOW_CPPS=False
    +
    +    # *ONO* Force MSYS2
    +    IS_WINDOWS=False
    +    SHOW_CPPS=True
    +    IS_MSYS2=True
    +
     elif os.name == 'posix':
         if os.uname()[0] == 'Darwin':
             IS_OSX=True
    @@ -2531,7 +2538,8 @@ def mk_config():
                 CPPFLAGS     = '%s -DNDEBUG -D_EXTERNAL_RELEASE' % CPPFLAGS
             if is_CXX_clangpp():
                 CXXFLAGS   = '%s -Wno-unknown-pragmas -Wno-overloaded-virtual -Wno-unused-value' % CXXFLAGS
    -        sysname, _, _, _, machine = os.uname()
    +        # sysname, _, _, _, machine = os.uname()
    +        sysname, machine = "MINGW32", "x86_64"
             if sysname == 'Darwin':
                 SO_EXT         = '.dylib'
                 SLIBFLAGS      = '-dynamiclib'
        
  • Run mk_make.py & build
    • python scripts/mk_build.py
    • cd build; make
  • When building, I noticed a lot of BDF errors, but I chose to ignore them and they didn’t seem to matter.
    bfd plugin: opt/maxlex.o: lseek: Bad file descriptor
    bfd plugin: opt/maxres.o: lseek: Bad file descriptor
    bfd plugin: opt/maxsmt.o: lseek: Bad file descriptor
    bfd plugin: opt/optsmt.o: lseek: Bad file descriptor
    bfd plugin: opt/opt_cmds.o: lseek: Bad file descriptor
    bfd plugin: opt/opt_context.o: lseek: Bad file descriptor
    bfd plugin: opt/opt_lns.o: lseek: Bad file descriptor
    bfd plugin: opt/opt_pareto.o: lseek: Bad file descriptor
    bfd plugin: opt/opt_parse.o: lseek: Bad file descriptor
    bfd plugin: opt/opt_solver.o: lseek: Bad file descriptor
    bfd plugin: opt/pb_sls.o: lseek: Bad file descriptor
    bfd plugin: opt/sortmax.o: lseek: Bad file descriptor
    bfd plugin: opt/wmax.o: lseek: Bad file descriptor
        
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment