google / re2

RE2 is a fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python. It is a C++ library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Linking issue with re2 on freebsd

chaitanyav opened this issue · comments

~/explore/ » uname -a                                                                                                                                                         
FreeBSD daemon-arena 13.2-STABLE FreeBSD 13.2-STABLE GENERIC amd64                                                                                                                                                                            

~/explore » clang++ -v                                                                                                                                                       
clang version 16.0.6
Target: x86_64-portbld-freebsd13.2
Thread model: posix
InstalledDir: /usr/local/llvm16/bin 
ld: error: undefined symbol: bool re2::re2_internal::Parse<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>(char const*, unsigned long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*)
>>> referenced by re2.h:886 (/usr/local/include/re2/re2.h:886)
>>>               ./build/release_clang/obj/extproc/http_job.o:(bool re2::RE2::Arg::DoParse3ary<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>(char const*, unsigned long, void*))

ld: error: undefined symbol: re2::RE2::Match(re2::StringPiece const&, unsigned long, unsigned long, re2::RE2::Anchor, re2::StringPiece*, int) const
re2-20230301
Name           : re2
Version        : 20230301
Installed on   : Fri Jul 28 18:12:03 2023 PDT
Origin         : devel/re2
Architecture   : FreeBSD:13:amd64
Prefix         : /usr/local
Categories     : devel
Licenses       : BSD3CLAUSE
Maintainer     : sunpoet@FreeBSD.org
WWW            : https://github.com/google/re2
Comment        : Fast C++ regex library
Shared Libs provided:
	libre2.so.10
Annotations    :
	FreeBSD_version: 1302505
	repo_type      : binary
	repository     : GhostBSD
Flat size      : 1.55MiB

It works for me.

It's not possible to undertake further investigation without information - I suggest you read https://docs.freebsd.org/en/articles/problem-reports/ or similar.

Firstly, a strong +1 to @peterjeremy's advice. Although there's some information above, there's zero information about what exact compiler/linker invocation failed. I'm also wondering whether you reported the breakage to your distribution first and, if so, what the outcome of that was; as yet, there's nothing to suggest that the breakage should have been reported upstream.

Secondly, did you attempt to debug this at all? In particular, did you try building RE2 from source? Also, is it actually the case that GhostBSD binary packages are expected to work on FreeBSD? You might have gotten lucky using C libraries in the past, but using C++ libraries may be troublesome due to ABI incompatibility caused by certain compiler/linker flags such as -std.

Lastly, I tagged that release of RE2 in March and FreeBSD picked it up in May, so it seems highly unlikely to have broken now. If something had truly broken, I imagine that folks like @sunpoet would have reported it well before now. As such, I'm closing this issue.

Thanks for looking into this. I understand that it may be because re2 port is not updated. I got into this issue when i was trying to build a new port for rethinkdb on freebsd. There are few things here

  1. The current port of re2 does not use abseil ( i intended to patch it but it was rejected https://bz-attachments.freebsd.org/attachment.cgi?id=243721)
PORTNAME=	re2
PORTVERSION=	20230301
CATEGORIES=	devel

MAINTAINER=	sunpoet@FreeBSD.org
COMMENT=	Fast C++ regex library
WWW=		https://github.com/google/re2

LICENSE=	BSD3CLAUSE
LICENSE_FILE=	${WRKSRC}/LICENSE

USES=		compiler:c++11-lang gmake pathfix

MAKE_ARGS=	CXX="${CXX}" CXXFLAGS="${CXXFLAGS}" SED_INPLACE="${SED} -i ''" prefix=${PREFIX}
USE_LDCONFIG=	yes

PATHFIX_MAKEFILEIN=	Makefile

GH_ACCOUNT=	google
GH_TAGNAME=	${PORTVERSION:C|(....)(..)(..)|\1-\2-\3|}
USE_GITHUB=	yes

post-install:
	${STRIP_CMD} ${STAGEDIR}${PREFIX}/lib/libre2.so

.include <bsd.port.mk>

When i started building the rethinkdb port

PORTNAME=	 rethinkdb
DISTVERSIONPREFIX = v
DISTVERSION=	2.4.3
CATEGORIES=	 databases
MASTER_SITES=	 https://rethinkdb.com/

MAINTAINER=	pnagato@protonmail.com
COMMENT=	The open-source database for the realtime web
WWW= https://rethinkdb.com/docs

LICENSE= APACHE20
LICENSE_FILE=   ${WRKSRC}/COPYRIGHT
ONLY_FOR_ARCHS=	amd64

USE_GITHUB=	yes
GH_ACCOUNT=	rethinkdb
GH_PROJECT=	rethinkdb
GH_TAGNAME= v2.4.3

USES=		gmake compiler:c++11-lang localbase pkgconfig
BUILD_DEPENDS=	protobuf>0:devel/protobuf \
	              llvm>0:devel/llvm \
	              ncurses>0:devel/ncurses \
	              boost-all>0:devel/boost-all \
	              python3>0:lang/python3 \
	              curl>0:ftp/curl \
	              wget>0:ftp/wget \
	              quickjs>0:lang/quickjs \
	              openssl>0:security/openssl \
	              googletest>0:devel/googletest

LIB_DEPENDS=	libprotobuf.so:devel/protobuf \
							libprotoc.so:devel/protobuf \
	            libncurses.so:devel/ncurses \
	            libcurl.so:ftp/curl \
	            libre2.so:devel/re2 \
	            libgtest.so:devel/googletest \
	            libboost_system.so:devel/boost-all \

GNU_CONFIGURE=	yes
CONFIGURE_ARGS= LDFLAGS=-L${LOCALBASE}/lib \
								LDFLAGS=-L${LOCALBASE}/lib/quickjs \
								CXXFLAGS=-I${LOCALBASE}/include
USE_LDCONFIG=	yes

do-configure:
	          cd ${WRKDIR}/${PORTNAME}-${DISTVERSION} && ./configure ${CONFIGURE_ARGS}

.include <bsd.port.mk>                                                  

And did a make stage

ld: error: undefined symbol: bool re2::re2_internal::Parse<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>(char const*, unsigned long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*)
>>> referenced by re2.h:886 (/usr/local/include/re2/re2.h:886)
>>>               ./build/release_clang/obj/http/http.o:(bool re2::RE2::Arg::DoParse3ary<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>(char const*, unsigned long, void*))

ld: error: undefined symbol: re2::RE2::Match(re2::StringPiece const&, unsigned long, unsigned long, re2::RE2::Anchor, re2::StringPiece*, int) const
>>> referenced by string.cc:86 (src/rdb_protocol/terms/string.cc:86)
>>>               ./build/release_clang/obj/rdb_protocol/terms/string.o:(ql::match_term_t::eval_impl(ql::scope_env_t*, ql::args_t*, ql::eval_flags_t) const)
c++: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[2]: *** [src/build.mk:346: build/release_clang/rethinkdb] Error 1
gmake[1]: *** [Makefile:53: make] Error 2                   

Now it all makes sense to me.

Was it something to do with RE2 being in LIB_DEPENDS, but not in BUILD_DEPENDS? :)

@chaitanyav The PR was rejected because of duplicate of an existing PR. Even if there's no existing PR, the patch would still be postponed. We have to check all dependent ports (you could get them by running "git grep devel/re2") before committing re2 update. That's why newer re2 is not in the ports tree yet. abseil is required since re2 20230601.