8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 18:43:02 +01:00

Merge pull request #7720 from FirebirdSQL/work/vcpkg-macos

MacOS: build libicu and static libc++ using vcpkg
This commit is contained in:
Adriano dos Santos Fernandes 2023-08-24 22:07:26 -03:00 committed by GitHub
commit 25b76bb26c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 215 additions and 116 deletions

View File

@ -261,114 +261,38 @@ jobs:
builds/install_images/Firebird-*-windows-*.zip
build-macos:
runs-on: macos-latest
runs-on: macos-12
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 10
submodules: 'true'
- name: Prepare - Install tools
run: |
brew install automake cmake libtool ninja
brew install automake autoconf-archive cmake libtool ninja
- name: Cache - libc++ install
id: cache-libcxx-install-macos
- name: Cache - vcpkg
uses: actions/cache@v3
with:
key: ${{ runner.os }}-libcxx-install-13.0.1
key: ${{ runner.os }}-vcpkg
path: |
extern/libcxx-macos-install
- name: Download libc++ sources
if: steps.cache-libcxx-install-macos.outputs.cache-hit != 'true'
run: |
mkdir extern/libcxx-macos
pushd extern/libcxx-macos
curl -OL https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.1/llvm-project-13.0.1.src.tar.xz
tar xJf llvm-project-13.0.1.src.tar.xz
popd
- name: Build libc++
if: steps.cache-libcxx-install-macos.outputs.cache-hit != 'true'
run: |
LIBCXX_BUILD_PATH=`pwd`/extern/libcxx-macos-build
LIBCXX_INSTALL_PATH=`pwd`/extern/libcxx-macos-install
mkdir $LIBCXX_BUILD_PATH
pushd extern/libcxx-macos/llvm-project-13.0.1.src
export MACOSX_DEPLOYMENT_TARGET=10.9
cmake -G Ninja -S llvm -B $LIBCXX_BUILD_PATH \
-DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi" \
-DCMAKE_INSTALL_PREFIX=$LIBCXX_INSTALL_PATH \
-DCMAKE_BUILD_TYPE=Release \
-DLIBCXX_ENABLE_SHARED=false \
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=true
ninja -C $LIBCXX_BUILD_PATH cxx cxxabi
ninja -C $LIBCXX_BUILD_PATH install-cxx install-cxxabi
popd
- name: Cache - libicu install
id: cache-libicu-install-macos
uses: actions/cache@v3
with:
key: ${{ runner.os }}-libicu-install-63.2
path: |
extern/libicu-macos-install
- name: Download and patch libicu sources
if: steps.cache-libicu-install-macos.outputs.cache-hit != 'true'
run: |
mkdir extern/libicu-macos
pushd extern/libicu-macos
curl -OL https://github.com/unicode-org/icu/releases/download/release-63-2/icu4c-63_2-src.tgz
curl -OL https://github.com/unicode-org/icu/commit/24aeb9a5a5874f4ce5db912e30670ac3ae236971.patch
tar xzf icu4c-63_2-src.tgz
cd icu/source
patch -p3 < ../../24aeb9a5a5874f4ce5db912e30670ac3ae236971.patch
popd
- name: Build libicu
if: steps.cache-libicu-install-macos.outputs.cache-hit != 'true'
run: |
export LIBTOOLIZE=glibtoolize
export LIBTOOL=glibtool
LIBICU_INSTALL_PATH=`pwd`/extern/libicu-macos-install
pushd extern/libicu-macos/icu/source
./runConfigureICU MacOSX --prefix=$LIBICU_INSTALL_PATH
make -j4
make install
install_name_tool -id @rpath/lib/libicuuc.dylib $LIBICU_INSTALL_PATH/lib/libicuuc.dylib
install_name_tool -id @rpath/lib/libicui18n.dylib $LIBICU_INSTALL_PATH/lib/libicui18n.dylib
install_name_tool -id @rpath/lib/libicudata.dylib $LIBICU_INSTALL_PATH/lib/libicudata.dylib
install_name_tool -change libicudata.63.dylib @loader_path/libicudata.63.dylib $LIBICU_INSTALL_PATH/lib/libicuuc.63.dylib
install_name_tool -change libicudata.63.dylib @loader_path/libicudata.63.dylib $LIBICU_INSTALL_PATH/lib/libicui18n.63.dylib
install_name_tool -change libicuuc.63.dylib @loader_path/libicuuc.63.dylib $LIBICU_INSTALL_PATH/lib/libicui18n.63.dylib
popd
$HOME/.cache/vcpkg/archives
- name: Build
run: |
export LIBTOOLIZE=glibtoolize
export LIBTOOL=glibtool
LIBCXX_INSTALL_PATH=`pwd`/extern/libcxx-macos-install
LIBICU_INSTALL_PATH=`pwd`/extern/libicu-macos-install
mkdir -p gen/Release/firebird/lib
cp -R $LIBICU_INSTALL_PATH/lib/libicu{data,i18n,uc}.*dylib gen/Release/firebird/lib/
export C_INCLUDE_PATH="$LIBICU_INSTALL_PATH/include:`xcrun --show-sdk-path`/usr/include"
export CPLUS_INCLUDE_PATH="$LIBCXX_INSTALL_PATH/include/c++/v1:$LIBICU_INSTALL_PATH/include:`xcrun --show-sdk-path`/usr/include"
export LIBRARY_PATH="$LIBCXX_INSTALL_PATH/lib:$LIBICU_INSTALL_PATH/lib:$LIBRARY_PATH"
./autogen.sh --with-builtin-tommath --with-builtin-tomcrypt
make -j4
make tests -j4
make run_tests
(cd gen; make -B -f make.platform.postfix ICU_LOC="$LIBICU_INSTALL_PATH/lib/")
(cd gen; make -B -f Makefile.install)
make -C gen -B -f make.platform.postfix
make -C gen -B -f Makefile.install
# Rename directory to make sure the build is relocatable.
mv gen gen2

5
.gitignore vendored
View File

@ -8,8 +8,8 @@ m4/
autom4te.cache/
builds/install_images
aclocal.m4
*.patch
*.diff
/*.patch
/*.diff
config.status
configure
config*~
@ -29,3 +29,4 @@ extern/ttmath/release/
/src/include/gen/autoconfig.auto
/src/include/gen/autoconfig.h
extern/libcds/lib/
/vcpkg_installed/

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "vcpkg"]
path = vcpkg
url = https://github.com/Microsoft/vcpkg.git

View File

@ -24,9 +24,6 @@ LIB_LINK_OPTIONS=$(LD_FLAGS) -dynamiclib -flat_namespace
LIB_LINK_SONAME:=-current_version @FIREBIRD_VERSION@ -compatibility_version @FIREBIRD_VERSION@ -seg1addr 0x30000000
LIB_LINK_MAPFILE=-Wl,-exported_symbols_list,$(1)
#EXE_LINK_OPTIONS+=-dylib_file /Library/Frameworks/Firebird.framework/Versions/A/Firebird ../gen/Release/firebird/lib/libfbclient.dylib
#LIB_LINK_RPATH:=-dylib_file /Library/Frameworks/Firebird.framework/Versions/A/Firebird ../gen/Release/firebird/lib/libfbclient.dylib
ADD_LIBS:=-lobjc -framework Foundation -framework Security
LINK_LIBS += $(ADD_LIBS)
STATICLINK_LIBS += $(ADD_LIBS)

View File

@ -19,5 +19,3 @@
#
# All Rights Reserved.
# Contributor(s): ______________________________________.
main

View File

@ -199,16 +199,16 @@ READELF = @READELF@
AC_CFLAGS = @CFLAGS@
AC_CXXFLAGS = @CXXFLAGS@
AC_LDFLAGS = @LDFLAGS@
# LINKER COMMANDS
# FIXME: -static-libstdc++ in MacOS
ifeq ($(PLATFORM),DARWIN)
LIB_LINK = $(CXX) $(GLOB_OPTIONS) $(CXXFLAGS)
EXE_LINK = $(CXX) $(GLOB_OPTIONS) $(CXXFLAGS)
LIB_LINK = $(CXX) $(GLOB_OPTIONS) $(CXXFLAGS) $(WLDFLAGS)
EXE_LINK = $(CXX) $(GLOB_OPTIONS) $(CXXFLAGS) $(WLDFLAGS)
else
LIB_LINK = $(CXX) $(GLOB_OPTIONS) $(CXXFLAGS) -static-libstdc++
EXE_LINK = $(CXX) $(GLOB_OPTIONS) $(CXXFLAGS) -static-libstdc++
LIB_LINK = $(CXX) $(GLOB_OPTIONS) $(CXXFLAGS) $(WLDFLAGS) -static-libstdc++
EXE_LINK = $(CXX) $(GLOB_OPTIONS) $(CXXFLAGS) $(WLDFLAGS) -static-libstdc++
endif
STATICLIB_LINK = $(AR) crus

View File

@ -68,6 +68,7 @@ endif
WCFLAGS = $(WFLAGS) $(CFLAGS) $(AC_CFLAGS) $(GLOB_OPTIONS)
WCXXFLAGS = $(WFLAGS) $(PLUSPLUS_FLAGS) $(PLATFORM_PLUSPLUS_FLAGS) $(CXXFLAGS) $(AC_CXXFLAGS) $(GLOB_OPTIONS)
WLDFLAGS = $(LDFLAGS) $(AC_LDFLAGS)
# Here we have definitions for using the preprocessor.

View File

@ -19,8 +19,6 @@
# 2 Oct 2002, Nickolay Samofatov - Major Cleanup
TARGET ?= Release
ICU_VERS = icu54
ICU_LOC ?= $(HOME)/$(ICU_VERS)/icu/source/lib/
FB_FW = ../gen/$(TARGET)/frameworks/Firebird5.framework
all: framework
@ -29,8 +27,6 @@ framework:
-$(RM) -rf $(FB_FW)
mkdir -p $(FB_FW)/Versions/A/Libraries
cp $(ICU_LOC)*.dylib ../gen/$(TARGET)/firebird/lib/
ln -s Versions/Current/Firebird $(FB_FW)/Firebird
ln -s Versions/Current/Headers $(FB_FW)/Headers
ln -s Versions/Current/Resources $(FB_FW)/Resources

View File

@ -38,7 +38,7 @@ export MACOSX_DEPLOYMENT_TARGET
PROD_FLAGS=-DDARWIN -DARM64 -pipe -O2 -MMD -fPIC -fno-common -mmacosx-version-min=11.0
DEV_FLAGS=-ggdb -DDARWIN -DARM64 -pipe -MMD -fPIC -fno-omit-frame-pointer -fno-common -Wall -fno-optimize-sibling-calls -mmacosx-version-min=11.0 -Wno-non-virtual-dtor
CXXFLAGS:=$(CXXFLAGS) -fvisibility-inlines-hidden -fvisibility=hidden -stdlib=libc++
CXXFLAGS:=$(CXXFLAGS) -fvisibility-inlines-hidden -fvisibility=hidden
UNDEF_PLATFORM=

View File

@ -33,7 +33,7 @@ export MACOSX_DEPLOYMENT_TARGET
PROD_FLAGS=-O1 -DDARWIN -pipe -MMD -fPIC -fno-common -mmacosx-version-min=10.7
DEV_FLAGS=-ggdb -DDARWIN -pipe -MMD -fPIC -fno-omit-frame-pointer -fno-common -Werror=delete-incomplete -Wall -fno-optimize-sibling-calls -mmacosx-version-min=10.7 -Wno-non-virtual-dtor
CXXFLAGS:=$(CXXFLAGS) -fvisibility-inlines-hidden -fvisibility=hidden -stdlib=libc++ -msse4
CXXFLAGS:=$(CXXFLAGS) -fvisibility-inlines-hidden -fvisibility=hidden -msse4
LD_FLAGS+=-liconv
FIREBIRD_LIBRARY_LINK+=-liconv

View File

@ -67,6 +67,26 @@ AC_CANONICAL_BUILD
CPU_TYPE=$build_cpu
AC_SUBST(CPU_TYPE)
case "$build" in
aarch64-*-darwin*)
VCPKG_TRIPLET=fb-arm64-osx
;;
x*64-*-darwin*)
VCPKG_TRIPLET=fb-x64-osx
;;
esac
if test "x$VCPKG_TRIPLET" != "x" ; then
if ! test -f ./vcpkg/vcpkg; then
./vcpkg/bootstrap-vcpkg.sh -disableMetrics
fi
./vcpkg/vcpkg install --triplet=$VCPKG_TRIPLET
VCPKG_INSTALLED=`pwd`/vcpkg_installed/$VCPKG_TRIPLET
AC_SUBST(VCPKG_INSTALLED)
fi
dnl EKU: set appropiate defaults for each platform
dnl EDITLINE_FLG : support fancy command line editing in isql
@ -669,6 +689,14 @@ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
LIBS="$LIBS $PTHREAD_LIBS"
case "$build" in
*-*-darwin*)
CFLAGS="$CFLAGS -I${VCPKG_INSTALLED}/include"
CXXFLAGS="$CXXFLAGS -nostdinc++ -isystem ${VCPKG_INSTALLED}/include/c++/v1 -I${VCPKG_INSTALLED}/include"
LDFLAGS="$LDFLAGS -nostdlib++ -stdlib=libc++ -L${VCPKG_INSTALLED}/lib -lc++"
;;
esac
AC_ARG_ENABLE(raw-devices,
[ --enable-raw-devices enable databases on raw devices (default on POSIX)],
[case "$enableval" in
@ -1397,6 +1425,18 @@ dnl # output
fi
fi
case "$build" in
*-*-darwin*)
cp -a $VCPKG_INSTALLED/lib/libicu* gen/\$fb_tgt/firebird/lib/
install_name_tool -id @rpath/lib/libicuuc.dylib gen/\$fb_tgt/firebird/lib/libicuuc.dylib
install_name_tool -id @rpath/lib/libicui18n.dylib gen/\$fb_tgt/firebird/lib/libicui18n.dylib
install_name_tool -id @rpath/lib/libicudata.dylib gen/\$fb_tgt/firebird/lib/libicudata.dylib
install_name_tool -change @rpath/libicudata.71.dylib @loader_path/libicudata.71.dylib gen/\$fb_tgt/firebird/lib/libicuuc.71.dylib
install_name_tool -change @rpath/libicudata.71.dylib @loader_path/libicudata.71.dylib gen/\$fb_tgt/firebird/lib/libicui18n.71.dylib
install_name_tool -change @rpath/libicuuc.71.dylib @loader_path/libicuuc.71.dylib gen/\$fb_tgt/firebird/lib/libicui18n.71.dylib
;;
esac
dnl ### TEMP ### directories for generated .cpp, .o and .d by module name
for src_dir in `cd src; ls -R -1 * | grep : | tr -d : | tr "\n" " "; cd ..`; do
mkdir -p temp/\$fb_tgt/\$src_dir

View File

@ -1,36 +1,56 @@
# Building Firebird on MacOSX using brew
# Building Firebird on MacOSX
## Preparing
- Install XCode
MacOS build uses `vcpkg` installed as git submodule:
```bash
git submodule update --init
```
Install XCode and dependencies with `homebrew`:
```bash
brew install automake autoconf-archive cmake libtool ninja
```
## Configuring
Set necessary environment variables:
```bash
brew install automake libtool icu4c
export CFLAGS=-I/usr/local/opt/icu4c/include
export LDFLAGS=-L/usr/local/opt/icu4c/lib
export CXXFLAGS=-I/usr/local/opt/icu4c/include
export LD_LIBRARY_PATH="/usr/local/opt/icu4c/lib:$LD_LIBRARY_PATH"
export LIBTOOLIZE=glibtoolize
export LIBTOOL=glibtool
```
## Configuring
In order to get Release build:
```bash
./autogen.sh --with-builtin-tommath --with-builtin-tomcrypt
```
## Building
In order to get Debug build:
In order to get Release build
```bash
./autogen.sh --with-builtin-tommath --with-builtin-tomcrypt --enable-developer
```
## Building
```bash
make -j4
```
In order to get Debug build
## Testing
```bash
make -j4 Debug
```
make tests -j4
make run_tests
```
## Packaging
```bash
make -C gen -B -f make.platform.postfix
make -C gen -B -f Makefile.install
```

1
vcpkg Submodule

@ -0,0 +1 @@
Subproject commit 417119555f155f6044dec7a379cd25466e339873

20
vcpkg-configuration.json Normal file
View File

@ -0,0 +1,20 @@
{
"default-registry": {
"kind": "git",
"repository": "https://github.com/Microsoft/vcpkg",
"baseline": "417119555f155f6044dec7a379cd25466e339873"
},
"registries": [
{
"kind": "filesystem",
"path": "vcpkg-custom/registry",
"baseline": "2023-08-23",
"packages": [
"libcxx"
]
}
],
"overlay-triplets": [
"vcpkg-custom/triplets"
]
}

View File

@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -e
SOURCE_PATH=@SOURCE_PATH@
INSTALL_PREFIX=@INSTALL_PREFIX@
export MACOSX_DEPLOYMENT_TARGET=10.9
cmake -G Ninja -S $SOURCE_PATH/llvm \
-DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \
-DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi" \
-DCMAKE_BUILD_TYPE=Release \
-DLIBCXX_ENABLE_SHARED=false \
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=true
ninja cxx cxxabi
ninja install-cxx install-cxxabi

View File

@ -0,0 +1,21 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO llvm/llvm-project
REF 75e33f71c2dae584b13a7d1186ae0a038ba98838
HEAD_REF llvmorg-13.0.1
SHA512 8bd80efe88160f615a9dc6fbcdab693d1459ca483410cf990f25169079e46726429f24ad042d287bfcfef8fd54a8a7264a67a710edaa24ebbf1e815a62b1f812
)
file(REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg" "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel")
set(BUILD_DIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel")
set(INSTALL_PREFIX "${CURRENT_PACKAGES_DIR}")
configure_file("${CMAKE_CURRENT_LIST_DIR}/build.sh.in" "${BUILD_DIR}/build.sh" @ONLY)
vcpkg_execute_required_process(
COMMAND "${SHELL}" ./build.sh
WORKING_DIRECTORY "${BUILD_DIR}"
LOGNAME "build-${TARGET_TRIPLET}-rel"
)

View File

@ -0,0 +1,5 @@
{
"name": "libcxx",
"version-string": "13.0.1",
"description": "LLVM libc++"
}

View File

@ -0,0 +1,7 @@
{
"2023-08-23": {
"libcxx": {
"baseline": "13.0.1"
}
}
}

View File

@ -0,0 +1,8 @@
{
"versions": [
{
"version": "13.0.1",
"path": "$/ports/libcxx/13.0.1_0"
}
]
}

View File

@ -0,0 +1,10 @@
set(VCPKG_TARGET_ARCHITECTURE arm64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CMAKE_SYSTEM_NAME Darwin)
set(VCPKG_OSX_ARCHITECTURES arm64)
if(PORT STREQUAL "icu")
set(VCPKG_LIBRARY_LINKAGE dynamic)
endif()

View File

@ -0,0 +1,10 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CMAKE_SYSTEM_NAME Darwin)
set(VCPKG_OSX_ARCHITECTURES x86_64)
if(PORT STREQUAL "icu")
set(VCPKG_LIBRARY_LINKAGE dynamic)
endif()

18
vcpkg.json Normal file
View File

@ -0,0 +1,18 @@
{
"name": "firebird",
"version-string": "5.0.0",
"dependencies": [
"icu",
"libcxx"
],
"overrides": [
{
"name": "icu",
"version": "71.1"
},
{
"name": "libcxx",
"version": "13.0.1"
}
]
}