How can build postgresql with LOCK_DEBUG enabled? - postgresql

I have been strugglling to build posqlgresql 9.1 with trace_locks on so I can check the memory addresses used by the locks, but after a couple of days effort, I still haven't made any progress.
to compile:
./configure --prefix=/usr/local/pgsql --enable-depend --enable-cassert --enable-debug
make
make install
According to postgresql documentation, LOCK_DEBUG should be set at compile time,
./configure --prefix=/usr/local/pgsql --enable-depend --enable-cassert --enable-debug LOCK_DEBUG='on'
but it doesn't seem like working.
Please help! Thanks!!!

I think you just want to get -DLOCK_DEBUG into the compiler flags, try it like this:
./configure \
--prefix=/usr/local/pgsql \
--enable-depend --enable-cassert \
--enable-debug \
CPPFLAGS='-DLOCK_DEBUG'
I added the backslashes to make it easier to read, you can use this if you want it all in one line:
./configure --prefix=/usr/local/pgsql --enable-depend --enable-cassert --enable-debug CPPFLAGS='-DLOCK_DEBUG'
You can find examples of similar things in the installation documentation, just search for "CFLAGS":
You can specify environment variables on the configure command line, for example:
./configure CC=/opt/bin/gcc CFLAGS='-O2 -pipe'

Related

How to install/start using swtpm on Linux

I am trying to start using TPM on Linux, on my Raspberry Pi to be accurate, and the easiest would be to use swtpm to get used to commands and system, before using a TPM chip. I've tried the way presented on https://github.com/stefanberger/swtpm/wiki#compile-on-ubuntu-2104, but I got the error "Unable to locate libtpms-dev".
Then I looked for a way to install libtpms, and found this one solution. But after getting those both, I still couldn't run this command :
sudo swtpm socket --tpmstate dir=/home/ludovic.peyter/swtpm --tpm2 --server type=tcp,port=2321 --ctrl type=tcp,port=2322 --flags not-need-init,startup-clear
All I get is the following error :
swtpm: SWTPM_NVRAM_Lock_Dir: Could not open lockfile: No such file or directory
and
swtpm: Error: Could not initialize libtpms.
And here am I stuck, finding nothing to help me with this problem, or even an other way to avoid it.
Thanks for reading.
I have a complete solution, built with many different solutions and my own tests.
sudo apt -y install dpkg-dev debhelper libssl-dev libtool net-tools libfuse-dev libglib2.0-dev libgmp-dev expect libtasn1-dev socat python3-twisted gnutls-dev gnutls-bin libjson-glib-dev gawk git python3-setuptools softhsm2 libseccomp-dev automake autoconf libtool gcc build-essential libssl-dev dh-exec pkg-config dh-autoreconf libtool-bin tpm2-tools libtss0 libtss2-dev
Then make a new directory for more comfort, and step into it.
Clone git repository for libtpms :
git clone https://github.com/stefanberger/libtpms.git
Move to the generated libtpms directory and run these commands :
./autogen.sh -–with-openssl
make dist
dpkg-buildpackage -us -uc -j4
Then, as asked at the end of the last running command, run :
libtool --finish /usr/lib/aarch64-linux-gnu/
The directory could be different, so pay attention to the warning at the end of dpkg command.
And to finish the installation of libtpms :
sudo apt install ../libtpms*.deb
Now get back to the previous directory and clone swtpm git repository :
git clone https://github.com/stefanberger/swtpm.git
Now run this command :
dpkg-buildpackage -us -uc -j4
And the command asked by the previous running command :
libtool --finish /usr/lib/aarch64-linux-gnu/swtpm
The directory could be different, so pay attention to the warning at the end of dpkg command.
Now finish the installation with this :
sudo apt install ../swtpm*.deb
Everithing you need is installed. Now you need to modify the file ~/.profile or ~/.bash_profile to add this line :
export TPM2TOOLS_TCTI="swtpm:port=2321"
And now, everytime you need your swtpm, open two terminals, and in one of them run :
swtpm socket --tpmstate dir=<swtpm_path> --tpm2 --server type=tcp,port=2321 --ctrl type=tcp,port=2322 --flags not-need-init,startup-clear
In the other terminal, as long as the above command runs, you can run all your TPM commands.
Have you checked that the tpmstate directory exists? A mkdir /home/ludovic.peyter/swtpm2 could fix it for you.

X11 problems when compiling openjdk 9 on centos 7

I find problems when I started to compile openjdk for my first time.
Below is what I did
hg clone http://hg.openjdk.java.net/jdk9/dev 9dev
cd 9dev
bash ./get_source.sh
bash ./configure
Then, I got this error message
configure: error: Could not find X11 libraries. You might be able to fix this by running 'sudo yum install libXtst-devel libXt-devel libXrender-devel libXi-devel'.
Then, I did what it told me to do.
After the installation, the same error still exists.
So I checked where the files lies on my machine
rpm -qa | grep X11
libX11-1.6.3-3.el7.x86_64
libX11-common-1.6.3-3.el7.noarch
libX11-devel-1.6.3-3.el7.x86_64
rpm -ql libX11-1.6.3-3.el7.x86_64
/usr/lib64/libX11-xcb.so.1
/usr/lib64/libX11-xcb.so.1.0.0
/usr/lib64/libX11.so.6
/usr/lib64/libX11.so.6.3.0
so i tried the way of specifying the X11 path
bash ./configure --x-libraries=/usr/lib64
Unfortunately, the same error still stays.
Can someone help me out of here, please?
thx
update
Thank #omajid for directing me to the log file config.log, where I found that the configure is using the gcc in my linuxbrew installation.
configure:56234: /data/alex/git/brew/bin/g++ -o conftest conftest.cpp -lX11 >&5
/data/alex/git/brew/bin/ld: cannot find -lX11
collect2: error: ld returned 1 exit status
configure:56234: $? = 1
So after I exported my c compiler to the system one, the problem was fixed.
export CC=/usr/bin/gcc
export CXX=/usr/bin/g++
Here is the relevant packages needed at build time and the configure flags I use in my spec file for building unofficial OpenJDK 9 packages for Fedora/EPEL:
autoconf
automake
alsa-lib-devel
binutils
cups-devel
desktop-file-utils
fontconfig
freetype-devel
elfutils
giflib-devel
gcc-c++
gdb
gtk2-devel
lcms2-devel
libjpeg-devel
libpng-devel
libxslt
libX11-devel
libXi-devel
libXinerama-devel
libXt-devel
libXtst-devel
nss-devel
pkgconfig
xorg-x11-proto-devel
zip
java-1.8.0-openjdk-devel
bash ../configure \
--with-boot-jdk=/usr/lib/jvm/java-1.8.0-openjdk/ \
--with-native-debug-symbols=internal \
--enable-unlimited-crypto \
--with-zlib=system \
--with-libjpeg=system \
--with-giflib=system \
--with-libpng=system \
--with-lcms=system \
--with-stdc++lib=dynamic \
--disable-javac-server \
--disable-warnings-as-errors
In any case, the error messages produce by configure are a best guess. You should take a look at config.log to see what test actually failed and what the error messages are. In this case, it looks like you are probably missing one of several X11 libraries. Possibly libXinerama-devel.
If this still doesn't fix your error, please paste the error messages from your autoconf log file (should be named config.log or configure.log, I forget).

How to cross-compile for RasPi3

I am currently trying to cross-compile Qt 5.7 for my Raspberry Pi 3. This is my first cross-compiling atempt, so please be kind. :)
On the Qt Wiki I found instructions for the Raspberry Pi 2, which I am currently trying to adapt.
The compile line for RasPi 2 is as follows:
./configure -release -opengl es2 -device linux-rasp-pi2-g++ -device-option \
CROSS_COMPILE=~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf- \
-sysroot ~/raspi/sysroot -opensource -confirm-license -make libs \
-prefix /usr/local/qt5pi -extprefix ~/raspi/qt5pi -hostprefix ~/raspi/qt5 -v
I replaced the option
-device linux-rasp-pi2-g++
by
-device linux-rpi3-g++
as I found within the raspi-tools folder.
Now I am stuck at the option
CROSS_COMPILE=~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-
as in the ~/raspi/tools/ folder I cannot see any obviously raspi3-related entry. There is only the arm-bcm2708/ folder. Shouldn't there be some bcm2837 entry? Does that mean there is no support for RasPi 3 yet or am I missing something?
Thank you for any hints.
After much struggle (the accepted solution does not work for me), I finally got to cross compile qt 5.6 for raspberry pi 3 on ubuntu.
You basically need to follow this well known how to. Just be sure to use the following configure:
./configure -release -opengl es2 -device linux-rpi3-g++
-device-option CROSS_COMPILE=~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-
-sysroot ~/raspi/sysroot -prefix /usr/local/qt5pi -extprefix ~/raspi/qt5pi -hostprefix ~/raspi/qt5 -v -nomake examples -nomake
tests -no-use-gold-linker
The arm-bcm2708/ folder is just a name. It contains several build tool chains. It's perfectly fine to use system-installed tool chains as well. So I installed the package g++-arm-linux-gnueabihf on my build machine (Debian GNU/Linux) and used this configure call:
./configure -release -opengl es2 -device linux-rpi3-g++ \
-device-option CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- \
-sysroot /home/fs/raspi/sysroot -opensource -confirm-license \
-make libs -prefix /usr/local/qt5pi -extprefix /home/fs/raspi/qt5pi \
-hostprefix /home/fs/raspi/qt5 -v

How build 64-bit version of libpq from source code?

I'm trying connect to PostgreSQL from C-code, and i have to build libpq from source, because i'm on AIX. I followed the steps in this comment
Where do i get libpq source?
but in result i got a 32-bit version of libpq.a, how build 64-bit version?
Compiling on AIX is harder than on other platforms...
Always create a script which you gradually improve till you get a working version. Possible start:
#!/bin/sh
#assuming gcc
GCCLIB=$(dirname $(gcc -maix64 -pthread -print-file-name=libgcc_s.a))
export CFLAGS='-maix64 -mtune=native -pthread'
export CPPFLAGS='-D_GNU_SOURCE -D_XOPEN_SOURCE=500 -D_ALL_SOURCE'
export LDFLAGS="-maix64 -Wl,-brtl -Wl,-blibpath:/usr/local/lib64:${GCCLIB}:/usr/lib -L/usr/local/lib64 -pthread"
export OBJECT_MODE=64
./configure --prefix=/usr/local \
--libdir=/usr/local/lib64 \
--enable-shared \
--enable-static \
2>&1 | tee log.configure
make all 2>&1 | tee log.make.all
make install 2>&1 | tee log.make.install
The -q64 compiler option enables 64 bit (there is info in the compiler docs)
A quick google search of xlC 64 bit gives this link which you might find helpful.
http://northstar-www.dartmouth.edu/doc/ibmcxx/en_US/doc/complink/tasks/tubld64a.htm

FFMPEG won't configure for iPhone

I have downloaded FFMPEG via svn, and put the gas-preprocessor into usr/local/bin. But, when I try to post the following code into terminal, it says: -bash: ./configure: No such file or directory
This is the code:
./configure
--cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc --as='gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc'
--sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk --enable-cross-compile --target-os=darwin --arch=arm --cpu=arm1176jzf-s --disable-pic --enable-gpl --enable-postproc --disable-debug --disable-stripping --enable-avfilter --enable-avfilter-lavf --extra-cflags='-arch armv6' --extra-ldflags='-arch armv6'
I am using Snow Leopard 10.6.1. What am I doing wrong?
Sometimes the shell script you're trying to run has the wrong path for the hashbang at the top of the file (which is then reported correctly but ambiguously as a missing file). Open up the configure script and check the path it's trying to run.
For example, take a look at the top of this configure script:
[on mymachine in directory sqsh-2.1.5]$ head -3 configure
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.59.
If for some reason /bin/sh does not exist, you'll get a file not found error.
The error is that it's not finding "configure" in the shell's current directory. What's your current working directory when you run this?