【Linux】在 Linux 上使用 Zig 编译 PostgreSQL 源码

6 篇文章 0 订阅
2 篇文章 0 订阅

安装Zig环境

请参考 在 Linux 上安装 Zig 编译环境

编译 PostgreSQL

下载 PostgreSQL 源码

通过 Github 下载源码,切换到目标标签

git clone https://github.com/postgres/postgres.git
cd postgres
git checkout REL_14_STABLE
sudo yum -y install readline-devel

使用 Zig 编译

执行如下命令:

export CC="zig cc" CXX="zig c++"
./configure
make -j
# zig cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Werror=unguarded-availability-new -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wno-unused-command-line-argument -Wno-compound-token-split-by-macro -Wno-deprecated-non-prototype -Wno-format-truncation -Wno-stringop-truncation -O2  zic.o -L../../src/port -L../../src/common   -Wl,--as-needed -Wl,-rpath,'/usr/local/pgsql/lib',--enable-new-dtags  -lpgcommon -lpgport -lz -lreadline -lm  -o zic
# error: unsupported linker arg: --enable-new-dtags
# make[2]: *** [zic] Error 1
# make[2]: Leaving directory `/data/postgres/src/timezone'
# make[1]: *** [all-timezone-recurse] Error 2
# make[1]: Leaving directory `/data/postgres/src'
# make: *** [all-src-recurse] Error 2

注意点:目前 Zig 最新版本不支持 --enable-new-dtags 这个连接器参数,不过在 Zig 最新代码中已经解决了,故可选择编码安装最新 Zig 。

  • 9
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值