Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions extensions/pgsql/AMBuilder
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ for cxx in builder.targets:
elif compiler.family == 'msvc':
compiler.cxxflags += ['/GR-']

if compiler.target.platform == 'linux' or compiler.target.platform == 'mac':
if compiler.target.platform == 'linux':
compiler.postlink += [
'-lz',
'-lpthread',
'-lm'
]
Expand All @@ -26,7 +25,8 @@ for cxx in builder.targets:
path = os.path.join(builder.sourcePath, 'extensions', 'pgsql', 'lib_linux64')
compiler.postlink += [
os.path.join(path, 'libpq.a'),
'-lrt'
os.path.join(path, 'libpgcommon_shlib.a'),
os.path.join(path, 'libpgport_shlib.a'),
]
elif compiler.target.platform == 'windows':
if arch == 'x86':
Expand All @@ -35,18 +35,17 @@ for cxx in builder.targets:
path = os.path.join(builder.sourcePath, 'extensions', 'pgsql', 'lib_win64')
compiler.postlink += [
os.path.join(path, 'libpq.lib'),
os.path.join(path, 'libpgcommon_shlib.lib'),
os.path.join(path, 'libpgport_shlib.lib'),
'wsock32.lib',
'ws2_32.lib',
'secur32.lib'
]
elif compiler.target.platform == 'mac':
if arch == 'x86':
path = os.path.join(builder.sourcePath, 'extensions', 'pgsql', 'lib_darwin')
elif arch == 'x86_64':
path = os.path.join(builder.sourcePath, 'extensions', 'pgsql', 'lib_darwin64')
compiler.postlink += [
os.path.join(path, 'libpq.a')
'secur32.lib',
'wldap32.lib',
'advapi32.lib',
'shell32.lib'
]
elif compiler.target.platform == 'mac': # mac isn't supported
continue

compiler.cxxincludes += [path]

Expand All @@ -59,4 +58,3 @@ for cxx in builder.targets:
'extension.cpp'
]
SM.extensions += [builder.Add(binary)]

88 changes: 74 additions & 14 deletions extensions/pgsql/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,82 @@
# PostgreSQL Build Instructions
As of writing, we're using PostgreSQL v9.6.9
# PostgreSQL Static Libraries

https://www.postgresql.org/ftp/source/
This extension bundles PostgreSQL 18.4 static libraries built by:

After building, libpq can be found in src/interfaces/libpq/
https://github.com/ProjectSky/build-postgresql-library

## Windows
https://www.postgresql.org/docs/9.6/install-windows-libpq.html
Use that project to rebuild or update the bundled libraries. It contains the
current PostgreSQL version, Linux configure flags, Windows Meson flags, and
release packaging details.

Change `src/interfaces/win32.mak` line 35 from `OPT=/O2 /MD` to `OPT=/O2 /MT`. Library will be in `interfaces\libpq\Release\libpq.lib`.
You have to delete the interfaces\libpq\Release folder between x86 and x86_64 builds.
## Manual Build

## Mac
For x86 or x86_64 add -m32 or -m64 to `CFLAGS`
The current build uses PostgreSQL `18.4`.

`CFLAGS='-mmacosx-version-min=10.7' ./configure && make`
1. Install the build dependencies.

## Linux
For x86 or x86_64 add -m32 or -m64 to `CFLAGS`
Linux requires `build-essential gcc-multilib g++-multilib`.

`CFLAGS='-fPIC' ./configure --without-readline && make`
Windows requires an MSVC developer shell, `winflexbison3`, `meson`, and
`ninja`.

2. Download and unpack [postgresql-18.4.tar.gz](https://ftp.postgresql.org/pub/latest/postgresql-18.4.tar.gz)

3. For Linux, create a separate build directory for each architecture and
configure with `--without-readline --without-icu --without-zlib`.

Use `CFLAGS="-fPIC -m32" LDFLAGS="-m32"` for `lib_linux`, or
`CFLAGS="-fPIC -m64" LDFLAGS="-m64"` for `lib_linux64`.

4. Build the Linux static libraries:

```sh
make -C src/backend generated-headers
make -C src/port libpgport_shlib.a
make -C src/common libpgcommon_shlib.a
make -C src/interfaces/libpq libpq.a SHLIB_PREREQS=
```

5. For Windows, configure from an MSVC developer shell:

```bat
python -m mesonbuild.mesonmain setup build-win64 . --backend=ninja -Dreadline=disabled -Dicu=disabled -Dlibcurl=disabled -Dzlib=disabled -Dssl=none -Db_vscrt=mt
```

6. Build the Windows static libraries:

```bat
python -m ninja -C build-win64 src/interfaces/libpq/libpq.a src/common/libpgcommon_shlib.a src/port/libpgport_shlib.a
```

Use `build-win32` from an x86 MSVC shell for `lib_win`.

7. Copy the three static libraries plus `libpq-fe.h` and `postgres_ext.h` into
the matching `lib_*` directory. Windows packages rename the `.a` outputs to
`.lib`.

## Bundled Files

Linux:

- `lib_linux/libpq.a`
- `lib_linux/libpgcommon_shlib.a`
- `lib_linux/libpgport_shlib.a`
- `lib_linux64/libpq.a`
- `lib_linux64/libpgcommon_shlib.a`
- `lib_linux64/libpgport_shlib.a`

Windows:

- `lib_win/libpq.lib`
- `lib_win/libpgcommon_shlib.lib`
- `lib_win/libpgport_shlib.lib`
- `lib_win64/libpq.lib`
- `lib_win64/libpgcommon_shlib.lib`
- `lib_win64/libpgport_shlib.lib`

Headers:

- `libpq-fe.h`
- `postgres_ext.h`

macOS pgsql builds are not currently supported.
Binary file removed extensions/pgsql/lib_darwin/libpq.a
Binary file not shown.
8 changes: 0 additions & 8 deletions extensions/pgsql/lib_darwin/pg_config_ext.h

This file was deleted.

Binary file removed extensions/pgsql/lib_darwin64/libpq.a
Binary file not shown.
8 changes: 0 additions & 8 deletions extensions/pgsql/lib_darwin64/pg_config_ext.h

This file was deleted.

Binary file added extensions/pgsql/lib_linux/libpgcommon_shlib.a
Binary file not shown.
Binary file added extensions/pgsql/lib_linux/libpgport_shlib.a
Binary file not shown.
Binary file modified extensions/pgsql/lib_linux/libpq.a
Binary file not shown.
8 changes: 0 additions & 8 deletions extensions/pgsql/lib_linux/pg_config_ext.h

This file was deleted.

Binary file added extensions/pgsql/lib_linux64/libpgcommon_shlib.a
Binary file not shown.
Binary file added extensions/pgsql/lib_linux64/libpgport_shlib.a
Binary file not shown.
Binary file modified extensions/pgsql/lib_linux64/libpq.a
Binary file not shown.
8 changes: 0 additions & 8 deletions extensions/pgsql/lib_linux64/pg_config_ext.h

This file was deleted.

Binary file added extensions/pgsql/lib_win/libpgcommon_shlib.lib
Binary file not shown.
Binary file added extensions/pgsql/lib_win/libpgport_shlib.lib
Binary file not shown.
Binary file modified extensions/pgsql/lib_win/libpq.lib
Binary file not shown.
7 changes: 0 additions & 7 deletions extensions/pgsql/lib_win/pg_config_ext.h

This file was deleted.

Binary file added extensions/pgsql/lib_win64/libpgcommon_shlib.lib
Binary file not shown.
Binary file added extensions/pgsql/lib_win64/libpgport_shlib.lib
Binary file not shown.
Binary file modified extensions/pgsql/lib_win64/libpq.lib
Binary file not shown.
7 changes: 0 additions & 7 deletions extensions/pgsql/lib_win64/pg_config_ext.h

This file was deleted.

Loading
Loading