intel / hyperscan

High-performance regular expression matching library
https://www.hyperscan.io
Other
4.78k stars 710 forks source link

build CHIMERA with pcre source failed #131

Open hardboydu opened 5 years ago

hardboydu commented 5 years ago

cmake

        cmake ../$HYPERSCAN \
                -DCMAKE_INSTALL_PREFIX=$PREFIX/$HYPERSCAN \
                -DCMAKE_C_COMPILER=$PREFIX/$GCC7/bin/gcc \
                -DCMAKE_CXX_COMPILER=$PREFIX/$GCC7/bin/g++ \
                -DCMAKE_BUILD_TYPE=Release \
                -DBUILD_STATIC_AND_SHARED=yes \
                -DBOOST_ROOT=$PREFIX/$BOOST \
                -DFAT_RUNTIME=true \
                -DBUILD_CHIMERA=true \
                -Wno-dev

log

In file included from /temp/hyperscan-5.0.0/pcre/pcre_byte_order.c:50:0:
/temp/hyperscan-5.0.0/pcre/pcre_internal.h:467:2: error: #error LINK_SIZE must be either 2, 3, or 4
 #error LINK_SIZE must be either 2, 3, or 4
  ^~~~~
hardboydu commented 5 years ago

如果不使用内置 pcre代码的话,使用 pcre 开发库则会出现如下错误

[ 94%] Linking CXX executable ../bin/unit-chimera
cd /temp/hyperscan-5.0.0-build/unit && cmake -E cmake_link_script CMakeFiles/unit-chimera.dir/link.txt --verbose=0
../lib/libchimera.a(ch_runtime.c.o): In function `scanPcre.isra.3':
ch_runtime.c:(.text+0x276): undefined reference to `_pcre_valid_utf'
collect2: error: ld returned 1 exit status
[ 94%] Linking CXX executable ../../bin/hscollider
cd /temp/hyperscan-5.0.0-build/tools/hscollider && cmake -E cmake_link_script CMakeFiles/hscollider.dir/link.txt --verbose=0
../../lib/libchimera.a(ch_runtime.c.o): In function `scanPcre.isra.3':
ch_runtime.c:(.text+0x276): undefined reference to `_pcre_valid_utf'
collect2: error: ld returned 1 exit status

如果将 ch_runtime.c 中 _pcre_valid_utf 替换成其他判断 UTF8 有效性的函数的话,可以编译成功

xiangwang1 commented 5 years ago

The reason you can't find _pcre_valid_utf() function is due to the fact that unicode support is by default off in PCRE. It is only enabled if you build PCRE with unicode support by specifying --enable-unicode-properties at configuration stage.

JackLiar commented 5 years ago

@xiangwang1 I've notice that there are unicode-properties setting in pcre.cmake

set(PCRE_SUPPORT_UNICODE_PROPERTIES ON CACHE BOOL "Build pcre with unicode")
add_subdirectory(${PCRE_SOURCE} ${PROJECT_BINARY_DIR}/pcre EXCLUDE_FROM_ALL)

however it is not working

I also ran cmake in the pcre source directory to see whether this option is on or off, it is on actually, but still gcc complains about that, so I have to manually run ./configure --enable-unicode-properties to make it work

environment:

HOWEVER, I tried the same cmake process on another two machines, one is:

the other one is:

these two machines worked like a charm!

I don't have too much experience on compiler or make/configure toolchain, where could the problem lies on exactly?

UPDATE I create a new CentOS environment using same gcc, and it works well, it seems like there is something wrong with the environment

but I still don't know what causes this difference...

simpleyetawesomeprojects commented 1 year ago

@hardboydu I'm trying to build chimera and seeing the same issue. Could you share the cmake command that ran successfully for you?

I'm using the following commands but I'm seeing error for __pcre_valid_utf

PLATFORM=mac mkdir -p $PLATFORM cd $PLATFORM INSTALL_PATH=pwd mkdir -p include lib mkdir -p include/hs echo "Decompressing hyperscan..." tar -xzvf ../hyperscan-$HYPERSCAN_VERSION.tar.gz

echo "Decompressing boost... this could take a while..." tar --totals -xf ../boost_$BOOST.tar.gz

cd boost_$BOOST ./bootstrap.sh --with-libraries=headers ./b2 headers cd ..

ln -sf $INSTALLPATH/boost$BOOST/boost $INSTALL_PATH/hyperscan-$HYPERSCAN_VERSION/include/boost

echo "Decompressing Ragel..." tar -xzvf ../ragel-$RAGEL_VERSION.tar.gz cd ragel-$RAGEL_VERSION ./configure --prefix="$INSTALL_PATH/.." make -j $MAKEJ make install cd ..

echo "Decompressing PCRE..." tar -xzvf ../pcre-$PCRE_VERSION.tar.gz mv pcre-$PCRE_VERSION hyperscan-$HYPERSCAN_VERSION

cd hyperscan-$HYPERSCAN_VERSION cd pcre-$PCRE_VERSION ./configure --enable-unicode-properties cd ..

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_INSTALL_LIBDIR="lib" -DARCH_OPT_FLAGS='-Wno-dev' -DBUILD_STATIC_LIBS=on -DPCRE_SOURCE="pcre-$PCRE_VERSION" .

make -j 4 make install/strip`