Skip to content

Commit

Permalink
Merge pull request #1 from davecramer/fix_x64_release
Browse files Browse the repository at this point in the history
Fix x64 release
  • Loading branch information
davecramer authored May 1, 2024
2 parents 4e1c125 + 50d5fcc commit 3cf30f5
Show file tree
Hide file tree
Showing 8 changed files with 186 additions and 39 deletions.
100 changes: 81 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,54 +184,116 @@ jobs:
sc config "postgresql-x64-14" start= auto
- name: get psqlodbc
uses: actions/checkout@v4
with:
submodules: true
- name: 'setup msvc for psqlodbc'
uses: TheMrMilchmann/setup-msvc-dev@v3
with:
arch: x86
- name: build psqlodbc

- name: build psqlodbc standard
shell: powershell
run: |
copy .github\workflows\configuration.xml winbuild
winbuild\BuildAll.ps1
installer\buildInstallers.ps1
- name: test psqlodbc
env:
PSQLODBC_OBJBASE: ${{ github.workspace }}\winbuild\standard
- name: test psqlodbc standard
shell: powershell
run: |
winbuild\regress.ps1 -DsnInfo "SERVER=localhost|DATABASE=contrib_regression|PORT=5432|UID=postgres|PWD=password"
- name: Upload x64 merge module
standard\test_x86\RegisterRegdsn.exe uninstall_driver postgres_devw
standard\test_x64\RegisterRegdsn.exe uninstall_driver postgres_devw
env:
PSQLODBC_OBJBASE: ${{ github.workspace }}\winbuild\standard

- name: build psqlodbc mimalloc
shell: powershell
run: |
copy .github\workflows\configuration.xml winbuild
winbuild\BuildAll.ps1 -UseMimalloc
installer\buildInstallers.ps1
env:
PSQLODBC_OBJBASE: ${{ github.workspace }}\winbuild\mimalloc
- name: test psqlodbc mimalloc
shell: powershell
run: |
winbuild\regress.ps1 -DsnInfo "SERVER=localhost|DATABASE=contrib_regression|PORT=5432|UID=postgres|PWD=password" -ExpectMimalloc
mimalloc\test_x86\RegisterRegdsn.exe uninstall_driver postgres_devw
mimalloc\test_x64\RegisterRegdsn.exe uninstall_driver postgres_devw
env:
PSQLODBC_OBJBASE: ${{ github.workspace }}\winbuild\mimalloc

- name: Upload standard x64 merge module
uses: actions/upload-artifact@v4
with:
name: psqlODBC Standard x64 Merge Module
path: winbuild/standard/installer/x64/*.msm
retention-days: 5
if-no-files-found: error
- name: Upload standard x64 installer package
uses: actions/upload-artifact@v4
with:
name: psqlODBC Standard x64 Installer
path: winbuild/standard/installer/x64/*.msi
retention-days: 5
if-no-files-found: error
- name: Upload standard x86 merge module
uses: actions/upload-artifact@v4
with:
name: psqlODBC Standard x86 Merge Module
path: winbuild/standard/installer/x86/*.msm
retention-days: 5
if-no-files-found: error
- name: Upload standard x86 installer package
uses: actions/upload-artifact@v4
with:
name: psqlODBC Standard x86 Installer
path: winbuild/standard/installer/x86/*.msi
retention-days: 5
if-no-files-found: error
- name: Upload standard x64 setup
uses: actions/upload-artifact@v4
with:
name: psqlODBC Standard x64 Setup
path: winbuild/standard/installer/psqlodbc-setup/bin/Release/psqlodbc-setup.exe
retention-days: 5
if-no-files-found: error

- name: Upload mimalloc x64 merge module
uses: actions/upload-artifact@v4
with:
name: psqlODBC x64 Merge Module
path: ./installer/x64/*.msm
name: psqlODBC mimalloc x64 Merge Module
path: winbuild/mimalloc/installer/x64/*.msm
retention-days: 5
if-no-files-found: error
- name: Upload x64 installer package
- name: Upload mimalloc x64 installer package
uses: actions/upload-artifact@v4
with:
name: psqlODBC x64 Installer
path: ./installer/x64/*.msi
name: psqlODBC mimalloc x64 Installer
path: winbuild/mimalloc/installer/x64/*.msi
retention-days: 5
if-no-files-found: error
- name: Upload x86 merge module
- name: Upload mimalloc x86 merge module
uses: actions/upload-artifact@v4
with:
name: psqlODBC x86 Merge Module
path: ./installer/x86/*.msm
name: psqlODBC mimalloc x86 Merge Module
path: winbuild/mimalloc/installer/x86/*.msm
retention-days: 5
if-no-files-found: error
- name: Upload x86 installer package
- name: Upload mimalloc x86 installer package
uses: actions/upload-artifact@v4
with:
name: psqlODBC x86 Installer
path: ./installer/x86/*.msi
name: psqlODBC mimalloc x86 Installer
path: winbuild/mimalloc/installer/x86/*.msi
retention-days: 5
if-no-files-found: error
- name: Upload x64 setup
id: x64_setup
- name: Upload mimalloc x64 setup
uses: actions/upload-artifact@v4
with:
name: psqlODBC x64 Setup
path: ./installer/psqlodbc-setup/bin/Release/psqlodbc-setup.exe
name: psqlODBC mimalloc x64 Setup
path: winbuild/mimalloc/installer/psqlodbc-setup/bin/Release/psqlodbc-setup.exe
retention-days: 5
if-no-files-found: error

Expand All @@ -243,4 +305,4 @@ jobs:
draft: false
prerelease: false
token: ${{secrets.RELEASE_TOKEN}}
artifacts: "./installer/x86/*.msi,./installer/x86/*.msm,./installer/psqlodbc-setup/bin/Release/psqlodbc-setup.exe"
artifacts: "winbuild/standard/installer/x64/*.ms?,winbuild/standard/installer/x86/*.ms?,winbuild/standard/installer/psqlodbc-setup/bin/Release/psqlodbc-setup.exe"
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "libs/mimalloc"]
path = libs/mimalloc
url = https://github.com/microsoft/mimalloc
branch = master
26 changes: 14 additions & 12 deletions inouealc.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#undef _MEMORY_DEBUG_
#include "psqlodbc.h"

#ifndef _MIMALLOC_
#ifdef WIN32
#ifdef _DEBUG
/* #include <stdlib.h> */
Expand All @@ -10,6 +11,7 @@
#include <malloc.h>
#endif /* _DEBUG */
#endif /* WIN32 */
#endif /* _MIMALLOC_ */
#include <string.h>

#include "misc.h"
Expand All @@ -26,20 +28,20 @@ CSTR ALCERR = "alcerr";
void * pgdebug_alloc(size_t size)
{
void * alloced;
alloced = malloc(size);
alloced = pg_malloc(size);
MYLOG(2, " alloced=%p(" FORMAT_SIZE_T ")\n", alloced, size);
if (alloced)
{
if (!alsize)
{
alsize = 100;
altbl = (ALADR *) malloc(alsize * sizeof(ALADR));
altbl = (ALADR *) pg_malloc(alsize * sizeof(ALADR));
}
else if (tbsize >= alsize)
{
ALADR *al;
alsize *= 2;
if (al = (ALADR *) realloc(altbl, alsize * sizeof(ALADR)), NULL == al)
if (al = (ALADR *) pg_realloc(altbl, alsize * sizeof(ALADR)), NULL == al)
return alloced;
altbl = al;
}
Expand All @@ -53,20 +55,20 @@ MYLOG(2, " alloced=%p(" FORMAT_SIZE_T ")\n", alloced, size);
}
void * pgdebug_calloc(size_t n, size_t size)
{
void * alloced = calloc(n, size);
void * alloced = pg_calloc(n, size);

if (alloced)
{
if (!alsize)
{
alsize = 100;
altbl = (ALADR *) malloc(alsize * sizeof(ALADR));
altbl = (ALADR *) pg_malloc(alsize * sizeof(ALADR));
}
else if (tbsize >= alsize)
{
ALADR *al;
alsize *= 2;
if (al = (ALADR *) realloc(altbl, alsize * sizeof(ALADR)), NULL == al)
if (al = (ALADR *) pg_realloc(altbl, alsize * sizeof(ALADR)), NULL == al)
return alloced;
altbl = al;
}
Expand All @@ -85,7 +87,7 @@ void * pgdebug_realloc(void * ptr, size_t size)

if (!ptr)
return pgdebug_alloc(size);
alloced = realloc(ptr, size);
alloced = pg_realloc(ptr, size);
if (!alloced)
{
MYLOG(0, "%s %p error\n", ALCERR, ptr);
Expand All @@ -109,7 +111,7 @@ void * pgdebug_realloc(void * ptr, size_t size)
}
char * pgdebug_strdup(const char * ptr)
{
char * alloced = strdup(ptr);
char * alloced = pg_strdup(ptr);
if (!alloced)
{
MYLOG(0, "%s %p error\n", ALCERR, ptr);
Expand All @@ -119,13 +121,13 @@ char * pgdebug_strdup(const char * ptr)
if (!alsize)
{
alsize = 100;
altbl = (ALADR *) malloc(alsize * sizeof(ALADR));
altbl = (ALADR *) pg_malloc(alsize * sizeof(ALADR));
}
else if (tbsize >= alsize)
{
ALADR *al;
alsize *= 2;
if (al = (ALADR *) realloc(altbl, alsize * sizeof(ALADR)), NULL == al)
if (al = (ALADR *) pg_realloc(altbl, alsize * sizeof(ALADR)), NULL == al)
return alloced;
altbl = al;
}
Expand Down Expand Up @@ -168,7 +170,7 @@ void pgdebug_free(void * ptr)
}
else
MYLOG(2, "ptr=%p\n", ptr);
free(ptr);
pg_free(ptr);
}

static BOOL out_check(void *out, size_t len, const char *name)
Expand Down Expand Up @@ -253,7 +255,7 @@ void debug_memory_check(void)
if (0 == tbsize)
{
MYLOG(0, "no memry leak found and max count allocated so far is %d\n", alsize);
free(altbl);
pg_free(altbl);
alsize = 0;
}
else
Expand Down
1 change: 1 addition & 0 deletions libs/mimalloc
Submodule mimalloc added at 229ec9
32 changes: 32 additions & 0 deletions psqlodbc.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#endif
#include "version.h"

#ifdef _MIMALLOC_
#include <stdlib.h>
#else /* _MIMALLOC_ */
#ifdef WIN32
#ifdef _DEBUG
#ifndef _MEMORY_DEBUG_
Expand All @@ -41,6 +44,11 @@
#else /* WIN32 */
#include <stdlib.h>
#endif /* WIN32 */
#endif /* _MIMALLOC_ */

#ifdef WIN32
#include <stdbool.h>
#endif /* WIN32 */

#ifdef __INCLUDE_POSTGRES_FE_H__ /* currently not defined */
/*
Expand All @@ -61,6 +69,21 @@
#endif /* __GNUC__ || __IBMC__ */
#endif /* __INCLUDE_POSTGRES_FE_H__ */

#ifdef _MIMALLOC_
#include <mimalloc.h>
#define pg_malloc mi_malloc
#define pg_realloc mi_realloc
#define pg_calloc mi_calloc
#define pg_strdup mi_strdup
#define pg_free mi_free
#else /* _MIMALLOC_ */
#define pg_malloc malloc
#define pg_realloc realloc
#define pg_calloc calloc
#define pg_strdup _strdup
#define pg_free free
#endif /* _MIMALLOC_ */

#ifdef _MEMORY_DEBUG_
void *pgdebug_alloc(size_t);
void *pgdebug_calloc(size_t, size_t);
Expand All @@ -87,6 +110,15 @@ void debug_memory_check(void);
/* #define strncpy_null pgdebug_strncpy_null */
#define memcpy pgdebug_memcpy
#define memset pgdebug_memset
#else /* _MEMORY_DEBUG_ */
#ifdef WIN32
#undef strdup
#endif /* WIN32 */
#define malloc pg_malloc
#define realloc pg_realloc
#define calloc pg_calloc
#define strdup pg_strdup
#define free pg_free
#endif /* _MEMORY_DEBUG_ */

#ifdef WIN32
Expand Down
28 changes: 26 additions & 2 deletions winbuild/BuildAll.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
Specify the configuration xml file name if you want to use
the configuration file other than standard one.
The relative path is relative to the current directory.
.PARAMETER UseMimalloc
Specify whether to use the mimalloc allocator for improved performance.
Requires a toolset of v141, v142 or later.
.EXAMPLE
> .\BuildAll
Build with default or automatically selected parameters.
Expand Down Expand Up @@ -65,7 +68,8 @@ Param(
[ValidateSet("Debug", "Release")]
[String]$Configuration="Release",
[string]$BuildConfigPath,
[switch]$AlongWithInstallers
[switch]$AlongWithInstallers,
[switch]$UseMimalloc
)

function buildPlatform([xml]$configInfo, [string]$Platform)
Expand Down Expand Up @@ -100,7 +104,27 @@ function buildPlatform([xml]$configInfo, [string]$Platform)
$BUILD_MACROS = $BUILD_MACROS -replace '"', '`"'
$macroList = iex "write-output $BUILD_MACROS"
}
& ${msbuildexe} ./platformbuild.vcxproj /tv:$MSToolsV "/p:Platform=$Platform;Configuration=$Configuration;PlatformToolset=${Toolset}" /t:$target /p:VisualStudioVersion=${VCVersion} /p:DRIVERVERSION=$DRIVERVERSION /p:PG_INC=$PG_INC /p:PG_LIB=$PG_LIB /p:PG_BIN=$PG_BIN $macroList

if ($UseMimalloc) {
$mimallocProperty = "yes"

switch ($VCVersion) {
"10.0" { $mimallocIdeDir = "vs2017" }
"11.0" { $mimallocIdeDir = "vs2017" }
"12.0" { $mimallocIdeDir = "vs2017" }
"14.0" { $mimallocIdeDir = "vs2017" }
"15.0" { $mimallocIdeDir = "vs2017" }
"16.0" { $mimallocIdeDir = "vs2019" }
"17.0" { $mimallocIdeDir = "vs2022" }
default { throw "Unable to resolve mimalloc IDE directory for VC ${VCVersion}."}
}

# build mimalloc dependency
& ${msbuildexe} ..\libs\mimalloc\ide\$mimallocIdeDir\mimalloc.vcxproj /tv:$MSToolsV "/p:Platform=$Platform;Configuration=$Configuration;PlatformToolset=${Toolset}" /t:$target /p:VisualStudioVersion=${VCVersion}
}

# build psqlodbc
& ${msbuildexe} ./platformbuild.vcxproj /tv:$MSToolsV "/p:Platform=$Platform;Configuration=$Configuration;PlatformToolset=${Toolset}" /t:$target /p:VisualStudioVersion=${VCVersion} /p:DRIVERVERSION=$DRIVERVERSION /p:PG_INC=$PG_INC /p:PG_LIB=$PG_LIB /p:PG_BIN=$PG_BIN /p:MIMALLOC=$mimallocProperty $macroList
}

$scriptPath = (Split-Path $MyInvocation.MyCommand.Path)
Expand Down
Loading

0 comments on commit 3cf30f5

Please sign in to comment.