From 9de65e05d4b267235ce949833b19e3b9915ee94b Mon Sep 17 00:00:00 2001 From: Ralph Lange Date: Tue, 27 Sep 2016 15:59:53 +0200 Subject: [PATCH 1/4] libCom/osi: fix timespec definition for MinGW (cherry-picked from 3.15) --- src/libCom/osi/os/WIN32/osdTime.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libCom/osi/os/WIN32/osdTime.h b/src/libCom/osi/os/WIN32/osdTime.h index 67fc83320..35848f6dc 100644 --- a/src/libCom/osi/os/WIN32/osdTime.h +++ b/src/libCom/osi/os/WIN32/osdTime.h @@ -14,11 +14,17 @@ #ifndef INC_osdTime_H #define INC_osdTime_H +/* MinGW only has a snippet time.h not protected against multiple inclusion */ +#if defined(__struct_timespec_defined) +#define _TIMESPEC_DEFINED 1 +#endif + #if ! defined(_MINGW) || ! defined(_TIMESPEC_DEFINED) # if _MSC_VER >= 1900 # include # else +#define __struct_timespec_defined 1 #define _TIMESPEC_DEFINED 1 struct timespec { time_t tv_sec; /* seconds since some epoch */ From c2b17feaf1c5aaf7f61b9132a7d7c0ee496ed891 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Tue, 27 Sep 2016 21:36:28 -0400 Subject: [PATCH 2/4] libCom: Missing unlock in epicsThreadShow for RTEMS fixes lp:1628323 --- src/libCom/osi/os/RTEMS/osdThread.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libCom/osi/os/RTEMS/osdThread.c b/src/libCom/osi/os/RTEMS/osdThread.c index b304026e0..8c8363e77 100644 --- a/src/libCom/osi/os/RTEMS/osdThread.c +++ b/src/libCom/osi/os/RTEMS/osdThread.c @@ -666,6 +666,7 @@ void epicsThreadShow (epicsThreadId id, unsigned int level) for (v = taskVarHead ; v != NULL ; v = v->forw) { if ((rtems_id)id == v->id) { epicsThreadShowInfo (v, level); + taskVarUnlock (); return; } } From 6623cb01125a61ea394c51e9e536e23a8ccb48b6 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 28 Sep 2016 17:10:38 -0500 Subject: [PATCH 3/4] Back-ported 64-bit MinGW cross-build stuff from 3.15 --- configure/os/CONFIG.Common.win32-x86-mingw | 1 + .../os/CONFIG.linux-x86.windows-x64-mingw | 22 +++++++++++++ .../os/CONFIG.linux-x86_64.windows-x64-mingw | 9 ++++++ .../os/CONFIG_SITE.linux-x86.win32-x86-mingw | 10 +++--- .../CONFIG_SITE.linux-x86.windows-x64-mingw | 23 ++++++++++++++ ...CONFIG_SITE.linux-x86_64.windows-x64-mingw | 8 +++++ documentation/RELEASE_NOTES.html | 31 +++++++++++++++++++ src/libCom/osi/os/WIN32/epicsGetopt.c | 4 +++ src/libCom/osi/os/WIN32/epicsGetopt.h | 8 +++++ src/libCom/osi/os/WIN32/osdThread.c | 2 +- 10 files changed, 113 insertions(+), 5 deletions(-) create mode 100644 configure/os/CONFIG.linux-x86.windows-x64-mingw create mode 100644 configure/os/CONFIG.linux-x86_64.windows-x64-mingw create mode 100644 configure/os/CONFIG_SITE.linux-x86.windows-x64-mingw create mode 100644 configure/os/CONFIG_SITE.linux-x86_64.windows-x64-mingw diff --git a/configure/os/CONFIG.Common.win32-x86-mingw b/configure/os/CONFIG.Common.win32-x86-mingw index a8390e6ef..8b83bf5b0 100644 --- a/configure/os/CONFIG.Common.win32-x86-mingw +++ b/configure/os/CONFIG.Common.win32-x86-mingw @@ -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 diff --git a/configure/os/CONFIG.linux-x86.windows-x64-mingw b/configure/os/CONFIG.linux-x86.windows-x64-mingw new file mode 100644 index 000000000..3692d6cb2 --- /dev/null +++ b/configure/os/CONFIG.linux-x86.windows-x64-mingw @@ -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 diff --git a/configure/os/CONFIG.linux-x86_64.windows-x64-mingw b/configure/os/CONFIG.linux-x86_64.windows-x64-mingw new file mode 100644 index 000000000..f84301266 --- /dev/null +++ b/configure/os/CONFIG.linux-x86_64.windows-x64-mingw @@ -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 + diff --git a/configure/os/CONFIG_SITE.linux-x86.win32-x86-mingw b/configure/os/CONFIG_SITE.linux-x86.win32-x86-mingw index 1d132b74d..cb624242b 100644 --- a/configure/os/CONFIG_SITE.linux-x86.win32-x86-mingw +++ b/configure/os/CONFIG_SITE.linux-x86.win32-x86-mingw @@ -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++ diff --git a/configure/os/CONFIG_SITE.linux-x86.windows-x64-mingw b/configure/os/CONFIG_SITE.linux-x86.windows-x64-mingw new file mode 100644 index 000000000..026410cfe --- /dev/null +++ b/configure/os/CONFIG_SITE.linux-x86.windows-x64-mingw @@ -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++ diff --git a/configure/os/CONFIG_SITE.linux-x86_64.windows-x64-mingw b/configure/os/CONFIG_SITE.linux-x86_64.windows-x64-mingw new file mode 100644 index 000000000..e98ac7a02 --- /dev/null +++ b/configure/os/CONFIG_SITE.linux-x86_64.windows-x64-mingw @@ -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 + diff --git a/documentation/RELEASE_NOTES.html b/documentation/RELEASE_NOTES.html index 10daf1016..bf44e11ab 100644 --- a/documentation/RELEASE_NOTES.html +++ b/documentation/RELEASE_NOTES.html @@ -13,6 +13,37 @@ +

MinGW Cross-builds from Linux

+ +

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.

+ +

The Linux MinGW cross-builds now use the compiler flags -static-libgcc +-static-libstdc++ 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.target 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):

+ +
+$ cp /usr/i686-w64-mingw32/sys-root/mingw/bin/libwinpthread-1.dll bin/win32-x86-mingw
+$ cp /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libwinpthread-1.dll bin/windows-x64-mingw
+
+ +

Some additional MinGW-specific changes have also been back-ported from the +Base-3.15 branch.

+

General Time updates

The iocInit code now performs a sanity check of the current time diff --git a/src/libCom/osi/os/WIN32/epicsGetopt.c b/src/libCom/osi/os/WIN32/epicsGetopt.c index 97bb11f47..1ea064ea2 100644 --- a/src/libCom/osi/os/WIN32/epicsGetopt.c +++ b/src/libCom/osi/os/WIN32/epicsGetopt.c @@ -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 */ diff --git a/src/libCom/osi/os/WIN32/epicsGetopt.h b/src/libCom/osi/os/WIN32/epicsGetopt.h index aa3bc7422..f92041085 100644 --- a/src/libCom/osi/os/WIN32/epicsGetopt.h +++ b/src/libCom/osi/os/WIN32/epicsGetopt.h @@ -12,6 +12,12 @@ #ifndef _EPICS_GETOPT_H #define _EPICS_GETOPT_H +#ifdef _MINGW + +#include + +#else /* _MINGW */ + #include "shareLib.h" #ifdef __cplusplus @@ -28,4 +34,6 @@ epicsShareExtern int optind, opterr, optopt; } #endif +#endif /* _MINGW */ + #endif /* _EPICS_GETOPT_H */ diff --git a/src/libCom/osi/os/WIN32/osdThread.c b/src/libCom/osi/os/WIN32/osdThread.c index 7f3d34500..5f61fc894 100644 --- a/src/libCom/osi/os/WIN32/osdThread.c +++ b/src/libCom/osi/os/WIN32/osdThread.c @@ -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; From 5ad61d25f6b44feddb3557cdb984dcc0c6f521ca Mon Sep 17 00:00:00 2001 From: Xiaoqiang Wang Date: Thu, 29 Sep 2016 11:23:14 -0500 Subject: [PATCH 4/4] Fix race condition in gdd --- src/gdd/gddAppTable.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gdd/gddAppTable.cc b/src/gdd/gddAppTable.cc index 92b0cacec..7a3890559 100644 --- a/src/gdd/gddAppTable.cc +++ b/src/gdd/gddAppTable.cc @@ -433,8 +433,10 @@ gddStatus gddApplicationTypeTable::freeDD(gdd* dd) } // fprintf(stderr,"Adding DD to free_list %d\n",app); + attr_table[group][app].sem.lock (); dd->setNext(attr_table[group][app].free_list); attr_table[group][app].free_list=dd; + attr_table[group][app].sem.unlock (); } else if (attr_table[group][app].type==gddApplicationTypeNormal) {