Skip to content

Commit

Permalink
Merge pull request #5 from haubi/master
Browse files Browse the repository at this point in the history
another step towards 2.0.0 release
  • Loading branch information
mduft authored Mar 10, 2020
2 parents bf3bd14 + cadcab4 commit 7cd4dd7
Show file tree
Hide file tree
Showing 64 changed files with 2,719 additions and 5,585 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ parity.gnu.ar/parity.gnu.ar
parity.gnu.gcc/parity.gnu.gcc
parity.gnu.ld/parity.gnu.ld
parity.gnu.nm/parity.gnu.dumpbin
parity.gnu.nm/parity.gnu.nm
parity.inspector/parity.inspector
parity.ms.cl/parity.ms.cl
parity.ms.link/parity.ms.lib
Expand Down
15 changes: 14 additions & 1 deletion Confix2.dir
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
IGNORE_FILE('config.h')
ADD_EXTRA_DIST('parity.sln')
ADD_EXTRA_DIST('ReleaseNotes.txt')

PARITYsupported_archs = ''
Expand Down Expand Up @@ -175,6 +174,17 @@ AC_DEFUN([PARITY_CONFIGURE],
AC_SUBST([PARITY_SUPPORTED_RUNTIMES], [$enable_msvc_runtimes])
AC_MSG_RESULT([$enable_msvc_runtimes])

AC_MSG_CHECKING([whether to support distinct binary packages per CHOST])
AC_ARG_ENABLE([binpkg-per-chost],
[AS_HELP_STRING([--enable-binpkg-per-chost],
[Support distinct binary packages per CHOST.])],
[AS_CASE([$enable_binpkg_per_chost],
[yes], [enable_binpkg_per_chost=yes],
[enable_binpkg_per_chost=no])],
[enable_binpkg_per_chost=no])
AC_SUBST([PARITY_BINPKG_PER_CHOST], [$enable_binpkg_per_chost])
AC_MSG_RESULT([$enable_binpkg_per_chost])

AC_MSG_CHECKING([whether to support Remote EXecution service])
AC_ARG_WITH([default-remote-execution-support],
[AS_HELP_STRING([--with-remote-execution-support=[[yes|no|enabled|disabled]]],
Expand Down Expand Up @@ -298,6 +308,8 @@ install-setup-files: install-recursive
$(MKDIR_P) "$(DESTDIR)$(localstatedir)"
"$(DESTDIR)$(bindir)/parity-setup" --destdir="$(DESTDIR)" --install
test -n "$(DESTDIR)" || "$(bindir)/parity-setup" --enable-all
test no = "$(PARITY_BINPKG_PER_CHOST)" || \\
sed -e '/^CHOSTS_TO_MANAGE=/s/builtin/installed/' -i "$(DESTDIR)$(bindir)/parity-setup"

install: install-setup-files

Expand All @@ -318,6 +330,7 @@ uninstall-setup-files:
rm -f cmd.exe ; \\
fi ; \\
done ; :
sed -e '/^CHOSTS_TO_MANAGE=/s/installed/builtin/' -i "$(DESTDIR)$(bindir)/parity-setup"
"$(DESTDIR)$(bindir)/parity-setup" --destdir="$(DESTDIR)" --uninstall ; :

uninstall-recursive: uninstall-setup-files
Expand Down
3 changes: 1 addition & 2 deletions Confix2.pkg
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ PACKAGE_VERSION('2.0.0')
from libconfix.setups.boilerplate import AutoBoilerplate
from libconfix.setups.c import AutoC
from libconfix.setups.automake import Automake
from libconfix.setups.cmake import CMake
from libconfix.setups.script import Script

SETUP([AutoBoilerplate(),
AutoC(),
Automake(use_libtool=False, library_dependencies=True),
CMake(library_dependencies=True), Script()])
Script()])

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
parity
======

Parity is a utility to compile native Windows executables and shared libraries using the Visual Studio compiler, from within a POSIX build environment like Microsoft SUA or Cygwin, providing a GCC like frontend. It provides various features, not available on Windows normally (runpaths, preloading, etc).
Parity is a utility to compile native Windows executables and shared libraries using the Visual Studio compiler, from within a POSIX build environment like Cygwin, providing a GCC like frontend, plus some runtime functions known from the POSIX world. Beyond that, the native Win32 programs built with parity are potentially able to deal with POSIX style path names.

Older versions of this project can be found here: https://sourceforge.net/projects/parity/
126 changes: 122 additions & 4 deletions ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,128 @@
parity is an open source project who's goal it is to ease porting applications from UNIX-like systems to Windows. It relies on the presence of a UNIX Layer for Windows such as Interix or Cygwin. parity is most tested on Microsofts Subsystem for UNIX-based Applications, so it will work there best.
parity is an open source project who's goal is to ease porting applications
from UNIX-like systems to Windows. It relies on the presence of a UNIX Layer
for Windows such as Interix or Cygwin. parity is most tested on x86_64 Cygwin,
so it will work there best.

parity uses the Microsoft Toolchain - like cl.exe, link.exe, etc. - to mimic a
GCC like interface, while really compiling natively for Windows. This results
in pure and native Windows Libraries and Executables, which can be mixed
freely with any existing Software pieces.

The most effort has been put into shared library handling, which now behaves
nearly the same as on common UNIX-like systems. There also is a patch for
libtool, which makes it know about parity (which passes almost all tests of
the libtool test-suite). Advanced Features like a working -rpath option have
been added to improve the handling of DLLs on Windows, but they were not
ported to x86_64 MSVC, and were not really necessary, so these have been
removed in parity 2.0.0 release.

parity ships with a little runtime enhancement library called parity.runtime.
This library abstracts away the need to take care of what kind of paths are
used. This means you can now give a UNIX-style path to an executable built
with parity, and it will understand it. Previously this was not possible, and
all Windows executables would need Windows-style paths to work.

parity 2.0.0
------------

Support up to Visual Studio 2019 (MSVC 16), and Visual Studio Build Tools.

Drop support for Visual Studio 2003 and older. Visual Studio 2005 (MSVC 8.0)
is the oldest one that still does run on Windows 10.

Support x86_64 (64bit) MSVC Toolchain.

Switch to Cygwin as build system, Interix and MSVC are unlikely to still work.

Use host triplet to identify the local MSVC Toolchain arch and version to be
used, and also to distinguish the MSVC runtime library variant. For example:
32bit (x86) dynamic multithreaded runtime: i686-msvc16-winnt
32bit (x86) static multithreaded runtime: i686-libcmt-winnt
64bit (x64) dynamic multithreaded debug runtime: x86_64-msvcd16-winnt
64bit (x64) static multithreaded debug runtime: x86_64-libcmtd16-winnt

Create symbolic links to MSVC import libraries, to avoid path components being
invalid as shell string (containing blanks or parentheses), for when the 8dot3
filename generation is disabled on the underlying file system.

Identify available Visual Studio or Build Tools instances using the registry
(pre VC15) or vswhere.exe (since VC15) rather than environment variables.

Provide environment values to be used when using MSVC toolchain without
parity, using the "parity-setup --get-environ i686-msvc16-winnt" command.

Disable concept of default MSVC versions, is hard to maintain. You always have
to use an MSVC version as part of the CHOST value.

Toolchain wrappers are installed as real executables, so the can run even from
within native Win32 build systems.

Support binary packaging of parity (using DESTDIR). Compiling the runtime libs
requiring local MSVC is done using the new parity-setup script after install.

Provide more POSIX/MinGW based wrappers: cpp, nm, strip (as noop), windres.

Provide more MSVC based wrappers (cmd, dumpbin, lib, nmake, rc), for build
systems that know about the MS toolchain when available via env vars.

Provide libtool patches, creating NAME.lib as the import library along
NAME.dll, and creating libNAME.lib as the static library. This implies
searching for NAME.lib upon the -lNAME linker option.

Support distinct binary packages per CHOST value, to have parity-setup enable
or disable installed CHOST values only rather than all the compiled in ones.
To be enabled using the --enable-binpkg-per-chost configure option.

Provide an exemplary parity.cygport, for building Cygwin binary packages.

parity.runtime: Stop switching stdio to binmode, almost everyone does expect
and can handle textmode with native winnt programs these days.

parity.runtime: Try to run cygpath from PATH for path conversion rather than
trying to dynamically load cygwin1.dll.

parity.runtime: Provide stdint.h, not available in older MSVC versions.

parity.runtime: Provide stdbool.h, not available before VS 2012.

parity.runtime: Provide stdarg.h, lacks va_copy() before VS 2012.

parity.runtime: Switch to StackWalk64 API when creating a backtrace.

parity.runtime: Have pid_t of type int, to allow for using pthreads4w
(https://sourceforge.net/projects/pthreads4w/).

parity.runtime: Provide clock_gettime(), wrapping timespec_get().

parity.loader: Stop caching dll handles. Provide dlclose() instead.

parity.gnu.gcc: Support the -include file option.

parity.gnu.gcc: Support --define, --undefine options.

parity.gnu.gcc: Support -std=c++XX and -ansi compiler options.

parity.gnu.gcc: Distinguish -Dmacro (value 1) from -Dmacro= (empty value).

parity.gnu.gcc: Distinguish --version from -v compiler option.

parity.gnu.gcc: Support -dumpmachine, -dumpversion, -print-prog-name,
-print-search-dirs commandline options.

parity.gnu.gcc: Improve support for assembly (.S) files.

parity.gnu.ld: Support Module Definition (.def) files when linking.

parity.gnu.ld: Support -Wl,--out-implib linker flag.

parity.gnu.ld: Upon -lNAME, search for NAME.dll.lib, as created by MinGW.

parity uses Microsoft Tools - like cl.exe, link.exe, etc. - to mimic a GCC like interface, while really compiling natively for Windows. This results in pure and native Windows Libraries and Executables, which can be mixed freely with any existing Software pieces.
parity.gnu.as: Relax from /Cp to /Cx assembler (ml.exe) flag.

The most effort has been put into shared library handling, which now behaves nearly the same as on common UNIX-like systems. There also is a patch for libtool, which makes it know about parity (which passes all tests of the libtool test-suite). Advanced Features like a working -rpath option have been added to improve the handling of DLLs on Windows.
parity.gnu.as: Run C preprocessor before assembling, the preprocessor
available within ml.exe uses a different syntax.

parity ships with a little runtime enhancement library called parity.runtime. This library abstracts away the need to take care of what kind of paths are used. This means you can now give a UNIX-style path to an executable built with parity, and it will understand it. Previously this was not possible, and all Windows executables would need Windows-style paths to work.
parity.ms.cl: Distinguish /c from /cygdrive/path compiler arguments.

parity 1.3.0
------------
Expand Down
127 changes: 127 additions & 0 deletions cygwin/parity.cygport
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
NAME="parity"
VERSION="2.0.0"
RELEASE="0.1"
CATEGORY="Devel"

MSVC_VERSIONS=(
# quoted from parity-setup, ignoring the old ones not running on Windows 10
# "<vcver> '<vsname>' <alternative-chost-version>"
# "7 'Visual Studio 2003' 7.1"
"8 'Visual Studio 2005' 8.0"
"9 'Visual Studio 2008' 9.0"
"10 'Visual Studio 2010' 10.0"
"11 'Visual Studio 2012' 11.0"
"12 'Visual Studio 2013' 12.0"
"14 'Visual Studio 2015' 14.0"
"15 'Visual Studio 2017'"
"16 'Visual Studio 2019'"
)

HOMEPAGE="https://github.com/mduft/parity"
SUMMARY="GCC like commandline wrapper for Visual Studio toolchain"
SRC_URI="${HOMEPAGE}/releases/download/${VERSION}/${NAME}-${VERSION}.tar.bz2"
SRC_DIR="${NAME}-${VERSION}"
DEPEND="autoconf-archive"
core_DESCRIPTION="\
Wraps the MSVC toolchain (cl.exe, link.exe, etc.)
providing a GCC like toolchain (gcc, g++, etc.)."

chosts-for-ver() {
local chostver=$1
local chost
for chost in \
i686-msvc${chostver}-winnt \
i686-msvcd${chostver}-winnt \
i686-libcmt${chostver}-winnt \
i686-libcmtd${chostver}-winnt \
x86_64-msvc${chostver}-winnt \
x86_64-msvcd${chostver}-winnt \
x86_64-libcmt${chostver}-winnt \
x86_64-libcmtd${chostver}-winnt \
; do
echo "${chost}"
done
}

one_pkgspecs() {
local vcver=$1
local vsname=$2
local chostver=$3
local pkgvarname="${NAME}_msvc${vcver}"
eval "${pkgvarname}_CATEGORY='${CATEGORY}'"
eval "${pkgvarname}_SUMMARY='${SUMMARY/Visual Studio/${vsname}}'"
eval "${pkgvarname}_DESCRIPTION='${core_DESCRIPTION/MSVC/MSVC ${chostver}}'"
eval "${pkgvarname}_CONTENTS='$(
echo "etc/postinstall/parity-msvc${vcver}.sh"
echo "etc/preremove/parity-msvc${vcver}.sh"
for chost in $(chosts-for-ver "${chostver}")
do
echo "usr/${chost}/"
echo "usr/bin/${chost}-*"
echo "etc/parity/${chost}/"
echo "var/parity/${chost}/"
done
)'"
}

all_pkgspecs() {
PKG_NAMES="${NAME}-core"
eval "${NAME}_core_CATEGORY='${CATEGORY}'"
eval "${NAME}_core_SUMMARY='${SUMMARY}'"
eval "${NAME}_core_DESCRIPTION='${core_DESCRIPTION}
Install ${NAME}-msvcXX matching your MSVC versions you want to utilize.'"
eval "${NAME}_core_CONTENTS='
etc/postinstall/${NAME}-core.sh
etc/preremove/${NAME}-core.sh
usr/bin/parity*
usr/lib/parity/
usr/libexec/
'"
PKG_IGNORE='
usr/share/
usr/lib/libparity_*
'
CYGCONF_ARGS=
local msvc_version verspecs vcver vsname chostver
for msvc_version in "${MSVC_VERSIONS[@]}"
do
# unbundle "<vcver> '<vsname>' <alternative-chost-version>"
eval "verspecs=( ${msvc_version} )"
vcver=${verspecs[0]}
vsname=${verspecs[1]}
chostver=${verspecs[2]:-${vcver}}

PKG_NAMES+=" ${NAME}-msvc${vcver}"
CYGCONF_ARGS+=",${chostver}"
one_pkgspecs "${vcver}" "${vsname}" "${chostver}"
done
CYGCONF_ARGS="--enable-binpkg-per-chost --enable-msvc-versions=${CYGCONF_ARGS#,}"
}

all_pkgspecs

src_install() {
cd ${B};
cyginstall
dodir /etc/postinstall
dodir /etc/preremove
echo "/usr/bin/${NAME}-setup --enable-all" > "${D}"/etc/postinstall/${NAME}-core.sh
echo "/usr/bin/${NAME}-setup --disable-all" > "${D}"/etc/preremove/${NAME}-core.sh
local msvc_version verspecs vcver vsname chostver
for msvc_version in "${MSVC_VERSIONS[@]}"
do
# unbundle "<vcver> '<vsname>' <alternative-chost-version>"
eval "verspecs=( ${msvc_version} )"
vcver=${verspecs[0]}
vsname=${verspecs[1]}
chostver=${verspecs[2]:-${vcver}}
cat > "${D}"/etc/postinstall/${NAME}-msvc${vcver}.sh <<-EOF
for chost in $(echo $(chosts-for-ver "${chostver}"))
do
/usr/bin/${NAME}-setup --enable \${chost} &
done
wait
EOF
echo /usr/bin/${NAME}-setup --disable $(chosts-for-ver "${chostver}") > "${D}"/etc/preremove/${NAME}-msvc${vcver}.sh
done
}
9 changes: 4 additions & 5 deletions parity.binary/CoffSection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@ namespace parity
// should not be required anymore hopefully...
//::memset(&struct_, 0, sizeof(struct_));

char buf[22] = {};
if(name.length() <= 8)
{
::strncpy(reinterpret_cast<char*>(struct_.Name), name.c_str(), 8);
::strncpy(buf, name.c_str(), 8);
} else {
::sprintf(reinterpret_cast<char*>(struct_.Name), "/%-7d", fh->addString(name));
::snprintf(buf, sizeof(buf), "/%-7d", fh->addString(name));
}
memcpy(struct_.Name, buf, 8);
}

Section::Section(Section const& rhs)
Expand Down Expand Up @@ -130,15 +132,12 @@ namespace parity

char* ptr = MAKEPTR(char*, fh->getBasePointer(), struct_.PointerToRelocations);

unsigned int numRelocs = struct_.NumberOfRelocations;

if(struct_.Characteristics & CharExtendedRelocations)
{
if(struct_.NumberOfRelocations != 0xFFFF)
throw utils::Exception("relocation overflow, but less than 0xFFFF relocations in section!");

Relocation first(ptr);
numRelocs = first.getVirtualAddress();
}

for(int i = 0; i < struct_.NumberOfRelocations; ++i)
Expand Down
4 changes: 3 additions & 1 deletion parity.binary/CoffSymbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ namespace parity

if(name.length() <= 8)
{
::strncpy(struct_.N.ShortName, name.c_str(), 8);
char buf[9];
::strncpy(buf, name.c_str(), 8);
memcpy(struct_.N.ShortName, buf, 8);
} else {
struct_.N.N.Zeros = 0;
struct_.N.N.Offset = fh->addString(name);
Expand Down
2 changes: 0 additions & 2 deletions parity.diagnostic/Diagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@

#include <psapi.h>

#pragma comment(lib, "psapi.lib")

#define BUFSIZE 512

BOOL GetFileNameFromHandle(HANDLE hFile, char* pszFilename, size_t length)
Expand Down
8 changes: 8 additions & 0 deletions parity.gnu.gcc/parity.gnu.gcc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ int main(int argc, char** argv)
context.setDefinesString("__PARITY_GNU__");
context.setDefinesString("__PARITY__");

//
// GNU C++ does set the __cplusplus macro value matching the
// selected C++ standard in use. It is a bug in the MSVC C++
// compiler to leave it on 199711L, but they decided to add
// another /Zc: compiler option for backwards compatibility.
//
context.setCplusPlusMacro(true);

Timing::instance().stop("Command Line Processing");

//
Expand Down
Loading

0 comments on commit 7cd4dd7

Please sign in to comment.