Skip to content

Refactor the whole project to improve portability and fix build on OpenBSD - #199

Open
ChihHao-Su wants to merge 4 commits into
mridoni:mainfrom
NPC-KFW-Server-Union:main
Open

ChihHao-Su wants to merge 4 commits into
mridoni:mainfrom
NPC-KFW-Server-Union:main

Conversation

@ChihHao-Su

Copy link
Copy Markdown

Tested on OpenBSD 7.3 and Fedora 41

This pull request has a series of modifications, let me explain:

Change the system-detecting logic (configure.ac)

The original configure.ac rejects configuration if the target system is not one of: windows (cygwin/msys), linux, macos. But, actually, this project has basically nothing platform-dependent. Therefore I modified this area of logic: the script will assume the project is able to build on every systems, it just needs to have some special handling for certain platforms.

Get fmt and spdlog via pkg-config instead of specifing -lfmt and -lspdlog flags directly

The libraries might have different filename than we thought, or inside some other directories. For example, on OpenBSD, some libraries are located in /usr/local/lib, for them, additional linker flags or compiler flags are needed.

Give another option for enabling mariadb

So that users can specify clearly whether he wants libmysqlclient or libmariadb.

Remove linker flags link to libstdc++

Target platform may not use libstdc++.

Prevent the including of build-tools/grammar-tools/FlexLexer.h on non-windows platform

build-tools/grammar-tools/FlexLexer.h, this file only works with GNU systems's flex. So just use FlexLexer.h of the system's flex.

Refactor yyin.getline into two overloaded yyinGetline function (libgixpp/GixEsqlLexer.cpp)

In OpenBSD's flex, yyin is a std::istream* instead of a std::istream.

Remove all #include <malloc.h>

This is useless, because there's already #include <stdlib.h>. And this file is not standard C header, doesn't exist on OpenBSD and some systems.

Provide a unified and cross-platform bitswap implementation (runtime/libgixsql/SqlVar.cpp)

To find the bitswap function of every system is troublesome, and you cannot find that on some systems, for example, OpenBSD. Let use a self-implemented one.

…dlog flags directly; Give another option for enabling mariadb; Remove linker flags link to libstdc++; Prevent the including of build-tools/grammar-tools/FlexLexer.h on non-windows platform; Remove all '#include <malloc.h>' (this problem also exist in OCESQL); Provide a unified and cross-platform bitswap implementation.
Comment thread runtime/libgixsql/SqlVar.cpp Outdated
Comment on lines +40 to +42
#define COB_BSWAP_16(val) bitswap16(val)
#define COB_BSWAP_32(val) bitswap32(val)
#define COB_BSWAP_64(val) bitswap64(val)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is wrong with the existing one (other than possibly the exact ifdefs)?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing one rely on platform-dependent things, it affects portability. It means you must implement COB_SWAP_XXX for every operating systems, I think it isn't necessary & beneficial for GixSQL to use bitswap function of the OSes.

Infact, this whole PR not only does the adaptation for OpenBSD, but also improves portability.

@GitMensch

Copy link
Copy Markdown
Contributor

@ChihHao-Su can you please split this PR, moving the bitswap one out to another one?

Comment thread gixpp/Makefile.am Outdated
bin_PROGRAMS = gixpp
gixpp_SOURCES = main.cpp popl.hpp
gixpp_CXXFLAGS = -std=c++17 -I.. -I $(top_srcdir)/common -I$(top_srcdir)/libcpputils -I$(top_srcdir)/libgixpp -I$(top_srcdir)/build-tools/grammar-tools
gixpp_CXXFLAGS = -std=c++17 -I.. -I $(top_srcdir)/common -I$(top_srcdir)/libcpputils -I$(top_srcdir)/libgixpp

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have -I$(top_builddir)/libgixpp as penultimate entry (as this is used for out-of-tree builds).

Comment thread configure.ac


# Check if the driver ID is valid
AS_IF([test "$with_default_driver" == "none" || test "$with_default_driver" == "odbc" || test "$with_default_driver" == "mysql" || test "$with_default_driver" == "pgsql" ] || test "$with_default_driver" == "oracle" ] || test "$with_default_driver" == "sqlite" ],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'd want to drop the \ here, see #170

@ChihHao-Su

Copy link
Copy Markdown
Author

@GitMensch Thank you, I will deal with these issues after a few days; I'm quite busy lately.

builds
2. Prioritize using the platform's bitswap functions
3. Fix a double quotes problem in configure.ac (mridoni#170)
@ChihHao-Su

Copy link
Copy Markdown
Author

I have solved these problem you mentioned.

can you please split this PR, moving the bitswap one out to another one?

Hi, I think it's much better to take this approach: We enumerate some platforms and the way to invoke their bitswap functionality, to use bitswap functionality provide by the target platform first, if target platform is not in the enumerate, we use a self-made bitswap implementation. I've done this.

@ChihHao-Su ChihHao-Su changed the title Fix build on OpenBSD Refactor the whole project to improve portability and fix build on OpenBSD Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants