Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build errors when enabling pcre2 on macOS #1495

Closed
ryandesign opened this issue Apr 20, 2024 · 2 comments
Closed

Build errors when enabling pcre2 on macOS #1495

ryandesign opened this issue Apr 20, 2024 · 2 comments

Comments

@ryandesign
Copy link
Contributor

ryandesign commented Apr 20, 2024

Building link-grammar 5.12.4 on macOS 12 fails for me:

libtool: compile:  /usr/bin/clang -DPACKAGE_NAME=\"link-grammar\" -DPACKAGE_TARNAME=\"link-grammar\" -DPACKAGE_VERSION=\"5.12.4\" "-DPACKAGE_STRING=\"link-grammar 5.12.4\"" -DPACKAGE_BUGREPORT=\"https://github.com/opencog/link-grammar\" -DPACKAGE_URL=\"https://opencog.github.io/link-grammar-website\" -DPACKAGE=\"link-grammar\" -DVERSION=\"5.12.4\" -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DYYTEXT_POINTER=1 -DHAVE_STRNDUP=1 -DHAVE_STRTOK_R=1 -DHAVE_SIGACTION=1 -DHAVE_ALIGNED_ALLOC=1 -DHAVE_POSIX_MEMALIGN=1 -DHAVE_ALLOCA_H=1 -DHAVE_ALLOCA=1 -DHAVE_FORK=1 -DHAVE_VFORK=1 -DHAVE_WORKING_VFORK=1 -DHAVE_WORKING_FORK=1 -D__STDC_FORMAT_MACROS=1 -D__STDC_LIMIT_MACROS=1 -DTLS=_Thread_local -DHAVE_PTHREAD_PRIO_INHERIT=1 -DHAVE_PTHREAD=1 -DHAVE_VISIBILITY=1 -DHAVE_LOCALE_T_IN_XLOCALE_H=1 -DHAVE_XLOCALE_H=1 -DHAVE_STDATOMIC_H=1 -DHAVE_MKLIT=1 -DUSE_SAT_SOLVER=1 -DUSE_WORDGRAPH_DISPLAY=1 -DHAVE_SQLITE3=1 -DHAVE_HUNSPELL=1 -DHUNSPELL_DICT_DIR=\"/Library/Spelling\" -DHAVE_EDITLINE=1 -DHAVE_WIDECHAR_EDITLINE=1 -DHAVE_PCRE2_H=1 -DHAVE_DECL_STRERROR_R=1 -DHAVE_STRERROR_R=1 -DVERSION=\"5.12.4\" -DDICTIONARY_DIR=\"/opt/local/share/link-grammar\" -DCC=\"/usr/bin/clang\" -I. -I.. -I.. -I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Werror-implicit-function-declaration -Wall -Wextra -Wsign-compare -Wpointer-arith -Wwrite-strings -Wmissing-declarations -Wpacked -Wswitch-enum -Wmissing-format-attribute -Wstrict-aliasing -Winit-self -Wshadow -Wno-missing-field-initializers -Wno-unused-parameter -Wno-attributes -Wno-long-long -Winline -I/opt/local/include/hunspell -pthread -D_DEFAULT_SOURCE -std=c11 -D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE -D_ISOC11_SOURCE -fvisibility=hidden -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -arch x86_64 -MT dict-common/regex-morph.lo -MD -MP -MF dict-common/.deps/regex-morph.Tpo -c dict-common/regex-morph.c  -fno-common -DPIC -o dict-common/.libs/regex-morph.o
dict-common/regex-morph.c:169:8: error: unknown type name 'once_flag'
static once_flag call_once_flag = ONCE_FLAG_INIT;
       ^
dict-common/regex-morph.c:169:35: error: use of undeclared identifier 'ONCE_FLAG_INIT'
static once_flag call_once_flag = ONCE_FLAG_INIT;
                                  ^
dict-common/regex-morph.c:170:8: error: unknown type name 'tss_t'
static tss_t re_md_key;
       ^
dict-common/regex-morph.c:173:11: error: implicit declaration of function 'tss_create' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        int rc = tss_create(&re_md_key, (tss_dtor_t) pcre2_match_data_free);
                 ^
dict-common/regex-morph.c:173:11: note: did you mean 'Exp_create'?
./dict-ram/dict-ram.h:25:7: note: 'Exp_create' declared here
Exp * Exp_create(Pool_desc *);
      ^
dict-common/regex-morph.c:173:35: error: use of undeclared identifier 'tss_dtor_t'
        int rc = tss_create(&re_md_key, (tss_dtor_t) pcre2_match_data_free);
                                         ^
dict-common/regex-morph.c:174:6: error: use of undeclared identifier 'thrd_success'
        if (thrd_success == rc) return;
            ^
dict-common/regex-morph.c:192:33: error: use of undeclared identifier 'nullptr'
        static pcre2_match_data *pmd = nullptr;
                                       ^
7 errors generated.

I can at least explain the last error: nullptr is a C++11 thing. You can't use C++ things in C code. In C, use NULL.

As for once_flag and ONCE_FLAG_INIT, those seems to be related to C11 threads, and macOS doesn't support C11 threads. The configure script correctly determined that threads.h does not exist.

My configure arguments were --prefix=/opt/local --disable-silent-rules --enable-editline --with-regexlib=pcre2 --disable-aspell --enable-hunspell --disable-java-bindings --disable-perl-bindings --disable-python-bindings --enable-sat-solver=bundled

My compilers are:

% /Library/Developer/CommandLineTools/usr/bin/clang --version
Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
% /Library/Developer/CommandLineTools/usr/bin/clang++ --version
Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
@ryandesign
Copy link
Contributor Author

If I use --disable-pcre2 --with-regexlib=c instead of --with-regexlib=pcre2 then it builds.

@ryandesign
Copy link
Contributor Author

Fixed by 34d1a1d, 94eed5c, and 77254ab.

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

No branches or pull requests

1 participant