Blog's RdHafidh

Building mesa 19.3.5 on ancient ubuntu

Suppose that you do maintain your own llvm gcc/clang based C++ toolchain for your own product sdk and you need to target wide range of linux glibc based distros, then below small patch tips might be useful for you.


1. Get your own gcc/clang install from your distro and recent llvm version >=7 or you can build from source as usual .

2. Grab mesa 19.3.5 and extract it somewhere

3. Apply following patch or you can revert following git commit



diff -ENwbur mesa-19.3.5/src/util/os_file.c mesa19/src/util/os_file.c
--- mesa-19.3.5/src/util/os_file.c	2020-03-10 03:36:39.093724300 +0700
+++ mesa19/src/util/os_file.c	2020-04-10 22:07:09.103647279 +0700
@@ -34,7 +34,7 @@
#if defined(__linux__)
@@ -135,9 +135,11 @@
os_same_file_description(int fd1, int fd2)
-   pid_t pid = getpid();
+ if (fd1 == fd2)
+      return true;
+ return false;
-   return syscall(SYS_kcmp, pid, pid, KCMP_FILE, fd1, fd2) == 0;

Linux kcmp syscall is only available since kernel 3.5, you can skip that execution and apply dummy simple integer comparation instead.

4. And perform build execution

meson -Dbuildtype=release -Dplatforms=x11 -Dshared-glapi=true -Dgles1=false -Dgles2=false -Dgbm=false -Dgallium-drivers=swrast -Ddri3=false -Dvulkan-drivers= build_dir

I’m not interested in targeting heavy high fps realtime 3d apps at the moment. Only llvmpipe and swrast backend cpu execution should enough for small 3d visualization apps, therefore some gpu vulkan drivers not currently being built. 

As noted from the manual manpage, the lightweight approach might be to expose suitable process information via the proc(5) file system, and it does expose some unsuitable security implications. 

Read More →

Building protobuf using MinGW on Windows

This is small tips on how to build Google protobuf on windows using mingw 8.1. You can skip from 
reading this tutorial and download from their binaries release instead for convenience.
Before digging into deeper compilation steps, please make sure that you had already installed of all the following tools:

  1. MinGW 8.x 
  2. CMake tools for windows.
  3. A mingw32-make.exe for windows. (Normally this tool is bundled from either MinGW zip download or it's official installer)

If all of above tools is already present, then we can continue to our build process.

  1.  Create windows batch file 

set CMAKEPATH=C:\cmake\bin 
set MINGWPATH=C:\mingw32 
set CC=gcc 
set CXX=g++ 
SET INCLUDE=%MINGWPATH%\include;%MINGWPATH%\i686-w64-mingw32\include;%MINGWPATH%\x86_64-w64-mingw32\include;%MINGWPATH%\opt\include 
SET LIB=%MINGWPATH%\lib;%MINGWPATH%\i686-w64-mingw32\lib;%MINGWPATH%\x86_64-w64-mingw32\lib;%MINGWPATH%\opt\lib 
SET PATH=%PATH%;%MINGWPATH%\bin;%MINGWPATH%\i686-w64-mingw32\bin;%MINGWPATH%\x86_64-w64-mingw32\bin;%CMAKEPATH%;%MINGWPATH%\opt\bin 

and save it to c:\windows\mingw8.bat
  1. Clone protobuf repo.
git clone
  1. Open command prompt and type mingw8. Enter following commands :
cd protobuf && mkdir ..\build && cmake.exe -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%MINGWPATH%\opt -G "MinGW Makefiles" ..\protobuf\cmake && mingw32-make
  1. You'll be greeted with following errors:

In file included from C:\mingw32/lib/gcc/i686-w64-mingw32/8.1.0/include/c++/bits/stl_algo.h:59,
                 from C:\mingw32/lib/gcc/i686-w64-mingw32/8.1.0/include/c++/algorithm:62,
                 from d:/git/protobuf/src/google/protobuf/stubs/common.h:38,
                 from d:/git/protobuf/src/google/protobuf/arena_impl.h:39,
                 from d:/git/protobuf/src/google/protobuf/arena.h:51,
                 from D:\masteraplikasi\transferh11nov\protobufgit\protobuf\src\google\protobuf\
	C:\mingw32/lib/gcc/i686-w64-mingw32/8.1.0/include/c++/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
	compilation terminated.
	mingw32-make[2]: *** [CMakeFiles/libprotobuf.dir/D_/git/protobuf/src/google/protobuf/] Error 1
	mingw32-make[1]: *** [CMakeFiles/libprotobuf.dir/all] Error 2
	mingw32-make: *** [all] Error 2

      The problem is that gcc treats -isystem differently than usual -I flag. So, to fix that we make sure append following additional cmake command 


for 32 build and for 64 build is like follows :


At the end, the following command is appropriate for 32 build:

cmake.exe -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES=%MINGWPATH%\i686-w64-mingw32\include -DCMAKE_INSTALL_PREFIX=%MINGWPATH%\opt ..\protobuf\cmake  -G "MinGW Makefiles" && mingw32-make && mingw32-make install

I hope you enjoy it, thanks for reading.


Read More →

Hello world of bloggin'

I am happy that I can release this personal blog to the public. Here I will try to share some tips from personal opinion with the hottest topics to the topic of programming languages and some free open source softwares.

(Image's courtsey of Google)







I hope you can enjoy to visit this site, thank you. smiley


Read More →