Back-ported 64-bit MinGW cross-build stuff from 3.15

This commit is contained in:
Andrew Johnson
2016-09-28 17:10:38 -05:00
parent c2b17feaf1
commit 6623cb0112
10 changed files with 113 additions and 5 deletions

View File

@ -9,6 +9,7 @@ include $(CONFIG)/os/CONFIG.Common.UnixCommon
OS_CLASS = WIN32
ARCH_CLASS = x86
POSIX = NO
# Definitions used when COMMANDLINE_LIBRARY is READLINE
LDLIBS_READLINE = -lreadline -lcurses

View File

@ -0,0 +1,22 @@
# CONFIG.linux-x86.windows-x64-mingw
#
# Definitions for linux-x86 host windows-x64-mingw target builds
# Override these definitions in CONFIG_SITE.linux-x86.windows-x64-mingw
#-------------------------------------------------------
# Include common gnu compiler definitions
include $(CONFIG)/CONFIG.gnuCommon
# Add resource compiler
RCCMD = $(GNU_BIN)/$(CMPLR_PREFIX)windres$(CMPLR_SUFFIX) $(INCLUDES) $< $@
# Remove -fPIC flags, add out-implib
SHRLIB_CFLAGS =
SHRLIB_LDFLAGS = -shared -Wl,--out-implib,$(LIB_PREFIX)$*$(LIB_SUFFIX)
LOADABLE_SHRLIB_LDFLAGS = -shared -Wl,--out-implib,$(LIB_PREFIX)$*$(LIB_SUFFIX)
# No need to explicitly link with gcc library
GNU_LDLIBS_YES =
# Link with system libraries
OP_SYS_LDLIBS = -lws2_32 -ladvapi32 -luser32 -lkernel32 -lwinmm

View File

@ -0,0 +1,9 @@
# CONFIG.linux-x86_64.windows-x64-mingw
#
# Definitions for linux-x86_64 host windows-x64-mingw target builds
# Override these definitions in CONFIG_SITE.linux-x86_64.windows-x64-mingw
#-------------------------------------------------------
# Settings as for the linux-x86 host architecture
include $(CONFIG)/os/CONFIG.linux-x86.windows-x64-mingw

View File

@ -5,10 +5,9 @@
# Early versions of the MinGW cross-build tools can only build
# static (non-DLL) libraries. Fedora's cross-build of gcc 4.4.6
# needs these uncommented, other distributions have not been
# tested with this release of Base:
SHARED_LIBRARIES = NO
STATIC_BUILD = YES
# needs these uncommented, cross-gcc 4.6.3 for Ubuntu does not:
#SHARED_LIBRARIES = NO
#STATIC_BUILD = YES
# The cross-build tools are in $(GNU_DIR)/bin
# Default is /usr
@ -21,3 +20,6 @@ STATIC_BUILD = YES
CMPLR_PREFIX = i686-pc-mingw32-
# Debian?
#CMPLR_PREFIX = i586-mingw32msvc-
# Use static compiler-support libraries
OP_SYS_LDFLAGS += -static-libgcc -static-libstdc++

View File

@ -0,0 +1,23 @@
# CONFIG_SITE.linux-x86.windows-x64-mingw
#
# Configuration for linux-x86 host windows-x64-mingw target builds
#-------------------------------------------------------
# Early versions of the MinGW cross-build tools can only build
# static (non-DLL) libraries. For example RHEL's cross-gcc 4.4.6
# needs these uncommented, cross-gcc 4.6.3 for Ubuntu does not:
#SHARED_LIBRARIES = NO
#STATIC_BUILD = YES
# The cross-build tools are in $(GNU_DIR)/bin
# Default is /usr
#GNU_DIR = /usr/local
# Different distribution cross-build packages use different prefixes:
# Ubuntu:
#CMPLR_PREFIX = i686-w64-mingw32-
# RHEL:
CMPLR_PREFIX = x86_64-w64-mingw32-
# Use static compiler-support libraries
OP_SYS_LDFLAGS += -static-libgcc -static-libstdc++

View File

@ -0,0 +1,8 @@
# CONFIG_SITE.linux-x86_64.windows-x64-mingw
#
# Configuration for linux-x86_64 host windows-x64-mingw target builds
#-------------------------------------------------------
# Inherit from the linux-x86 host architecture
include $(CONFIG)/os/CONFIG_SITE.linux-x86.windows-x64-mingw

View File

@ -13,6 +13,37 @@
<!-- Insert new items immediately below here ... -->
<h3>MinGW Cross-builds from Linux</h3>
<p>Build configuration files have been back-ported from the 3.15 branch that
allow cross-building of the windows-x64-mingw target from either linux-x86 or
linux-x86_64 hosts. Similar support for the 32-bit win32-x86-mingw cross-target
was added in Base-3.14.12.5. Adjust the settings in the configuration file
configure/os/CONFIG_SITE.linux-x86.windows-x64-mingw and add windows-x64-mingw
to the CROSS_COMPILER_TARGET_ARCHS variable in configure/CONFIG_SITE or in
configure/os/CONFIG_SITE.linux-x86.Common.</p>
<p>The Linux MinGW cross-builds now use the compiler flags <tt>-static-libgcc
-static-libstdc++</tt> which avoids having to copy some DLLs onto the Windows
system to be able to run the generated binaries. These compiler flags can be
disabled by editing the configure/os/CONFIG_SITE.linux-x86.<i>target</i> file
for Linux distributions where the cross-build toolset doesn't make static
versions of those libraries available. The RHEL-6.8 MinGW toolset does not
package a static version of the library winpthread-1 so on that host OS it is
still necessary to provide a copy of the libwinpthread-1.dll file for the
Windows system to use. The simplest way to do this is to manually copy it into
the IOC application's bin/win32-x86-mingw or bin/windows-x64-mingw directory
after building the IOC, like this (note that Windows DLLs are always installed
into the bin directory, not the lib directory):</p>
<blockquote><pre>
<b>$</b> cp /usr/i686-w64-mingw32/sys-root/mingw/bin/libwinpthread-1.dll bin/win32-x86-mingw
<b>$</b> cp /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libwinpthread-1.dll bin/windows-x64-mingw
</pre></blockquote>
<p>Some additional MinGW-specific changes have also been back-ported from the
Base-3.15 branch.</p>
<h3>General Time updates</h3>
<p>The <tt>iocInit</tt> code now performs a sanity check of the current time

View File

@ -1,3 +1,5 @@
#ifndef _MINGW
/*
* Copyright (c) 1987, 1993, 1994
* The Regents of the University of California. All rights reserved.
@ -121,3 +123,5 @@ int getopt(nargc, nargv, ostr)
}
return (optopt); /* dump back option letter */
}
#endif /* !_MINGW */

View File

@ -12,6 +12,12 @@
#ifndef _EPICS_GETOPT_H
#define _EPICS_GETOPT_H
#ifdef _MINGW
#include <unistd.h>
#else /* _MINGW */
#include "shareLib.h"
#ifdef __cplusplus
@ -28,4 +34,6 @@ epicsShareExtern int optind, opterr, optopt;
}
#endif
#endif /* _MINGW */
#endif /* _EPICS_GETOPT_H */

View File

@ -92,7 +92,7 @@ static const int osdRealtimePriorityList [osdRealtimePriorityStateCount] =
#if !defined(EPICS_DLL_NO)
BOOL WINAPI DllMain (
HANDLE hModule, DWORD dwReason, LPVOID lpReserved )
HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved )
{
static DWORD dllHandleIndex;
HMODULE dllHandle = 0;