llvm.org GIT mirror llvm / ee03c94
Add basic zlib support to LLVM. This would allow to use compression/uncompression in selected LLVM tools. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180083 91177308-0d34-0410-b5e6-96231b3b80d8 Alexey Samsonov 6 years ago
16 changed file(s) with 589 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
123123
124124 option(LLVM_ENABLE_THREADS "Use threads if available." ON)
125125
126 option(LLVM_ENABLE_ZLIB "Use zlib for compression/decompression if available." ON)
127
126128 if( LLVM_TARGETS_TO_BUILD STREQUAL "all" )
127129 set( LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS} )
128130 endif()
301301 # Do we want to enable threads?
302302 ENABLE_THREADS := @LLVM_ENABLE_THREADS@
303303
304 # Do we want to enable zlib?
305 ENABLE_ZLIB := @LLVM_ENABLE_ZLIB@
306
304307 # Do we want to build with position independent code?
305308 ENABLE_PIC := @ENABLE_PIC@
306309
707707 *) AC_MSG_ERROR([Invalid setting for --enable-pthreads. Use "yes" or "no"]) ;;
708708 esac
709709
710 dnl Allow disablement of zlib
711 AC_ARG_ENABLE(zlib,
712 AS_HELP_STRING([--enable-zlib],
713 [Use zlib for compression/decompression if
714 available (default is YES)]),,
715 enableval=default)
716 case "$enableval" in
717 yes) AC_SUBST(LLVM_ENABLE_ZLIB,[1]) ;;
718 no) AC_SUBST(LLVM_ENABLE_ZLIB,[0]) ;;
719 default) AC_SUBST(LLVM_ENABLE_ZLIB,[1]) ;;
720 *) AC_MSG_ERROR([Invalid setting for --enable-zlib. Use "yes" or "no"]) ;;
721 esac
722 AC_DEFINE_UNQUOTED([LLVM_ENABLE_ZLIB],$LLVM_ENABLE_ZLIB,
723 [Define if zlib is enabled])
724
710725 dnl Allow building without position independent code
711726 AC_ARG_ENABLE(pic,
712727 AS_HELP_STRING([--enable-pic],
13651380 AC_SEARCH_LIBS(pthread_getspecific,pthread,
13661381 AC_DEFINE([HAVE_PTHREAD_GETSPECIFIC],[1],
13671382 [Have pthread_getspecific]))
1383 fi
1384
1385 dnl zlib is optional; used for compression/uncompression
1386 if test "$LLVM_ENABLE_ZLIB" -eq 1 ; then
1387 AC_CHECK_LIB(z, compress2)
13681388 fi
13691389
13701390 dnl Allow extra x86-disassembler library
15011521 else
15021522 AC_SUBST(HAVE_PTHREAD, 0)
15031523 fi
1524 if test "$LLVM_ENABLE_ZLIB" -eq 1 ; then
1525 AC_CHECK_HEADERS(zlib.h,
1526 AC_SUBST(HAVE_LIBZ, 1),
1527 AC_SUBST(HAVE_LIBZ, 0))
1528 else
1529 AC_SUBST(HAVE_LIBZ, 0)
1530 fi
15041531
15051532 dnl Try to find ffi.h.
15061533 if test "$llvm_cv_enable_libffi" = "yes" ; then
7878 check_include_file(utime.h HAVE_UTIME_H)
7979 check_include_file(valgrind/valgrind.h HAVE_VALGRIND_VALGRIND_H)
8080 check_include_file(windows.h HAVE_WINDOWS_H)
81 check_include_file(zlib.h HAVE_ZLIB_H)
8182 check_include_file(fenv.h HAVE_FENV_H)
8283 check_symbol_exists(FE_ALL_EXCEPT "fenv.h" HAVE_DECL_FE_ALL_EXCEPT)
8384 check_symbol_exists(FE_INEXACT "fenv.h" HAVE_DECL_FE_INEXACT)
103104 endif()
104105 check_library_exists(dl dlopen "" HAVE_LIBDL)
105106 check_library_exists(rt clock_gettime "" HAVE_LIBRT)
107 check_library_exists(z compress2 "" HAVE_LIBZ)
106108 endif()
107109
108110 # function checks
449451 message(STATUS "Threads disabled.")
450452 endif()
451453
454 if (LLVM_ENABLE_ZLIB )
455 # Check if zlib is available in the system.
456 if ( NOT HAVE_ZLIB_H OR NOT HAVE_LIBZ )
457 set(LLVM_ENABLE_ZLIB 0)
458 endif()
459 endif()
460
452461 set(LLVM_PREFIX ${CMAKE_INSTALL_PREFIX})
1111 endif()
1212 if( LLVM_ENABLE_THREADS AND HAVE_LIBPTHREAD )
1313 set(system_libs ${system_libs} pthread)
14 endif()
15 if ( LLVM_ENABLE_ZLIB AND HAVE_LIBZ )
16 set(system_libs ${system_libs} z)
1417 endif()
1518 endif( MINGW )
1619 endif( NOT MSVC )
2121
2222 set(LLVM_ENABLE_THREADS @LLVM_ENABLE_THREADS@)
2323
24 set(LLVM_ENABLE_ZLIB @LLVM_ENABLE_ZLIB@)
25
2426 set(LLVM_NATIVE_ARCH @LLVM_NATIVE_ARCH@)
2527
2628 set(LLVM_ENABLE_PIC @LLVM_ENABLE_PIC@)
2729
2830 set(HAVE_LIBDL @HAVE_LIBDL@)
2931 set(HAVE_LIBPTHREAD @HAVE_LIBPTHREAD@)
32 set(HAVE_LIBZ @HAVE_LIBZ@)
3033 set(LLVM_ON_UNIX @LLVM_ON_UNIX@)
3134 set(LLVM_ON_WIN32 @LLVM_ON_WIN32@)
3235
702702 ENABLE_DOXYGEN
703703 LLVM_ENABLE_THREADS
704704 ENABLE_PTHREADS
705 LLVM_ENABLE_ZLIB
705706 ENABLE_PIC
706707 ENABLE_SHARED
707708 ENABLE_EMBED_STDCXX
776777 LIBXML2_LIBS
777778 LIBXML2_INC
778779 HAVE_PTHREAD
780 HAVE_LIBZ
779781 HUGE_VAL_SANITY
780782 MMAP_FILE
781783 SHLIBEXT
14251427 --enable-doxygen Build doxygen documentation (default is NO)
14261428 --enable-threads Use threads if available (default is YES)
14271429 --enable-pthreads Use pthreads if available (default is YES)
1430 --enable-zlib Use zlib for compression/decompression if available
1431 (default is YES)
14281432 --enable-pic Build LLVM with Position Independent Code (default
14291433 is YES)
14301434 --enable-shared Build a shared library and link tools against it
54775481 { (exit 1); exit 1; }; } ;;
54785482 esac
54795483
5484 # Check whether --enable-zlib was given.
5485 if test "${enable_zlib+set}" = set; then
5486 enableval=$enable_zlib;
5487 else
5488 enableval=default
5489 fi
5490
5491 case "$enableval" in
5492 yes) LLVM_ENABLE_ZLIB=1
5493 ;;
5494 no) LLVM_ENABLE_ZLIB=0
5495 ;;
5496 default) LLVM_ENABLE_ZLIB=1
5497 ;;
5498 *) { { echo "$as_me:$LINENO: error: Invalid setting for --enable-zlib. Use \"yes\" or \"no\"" >&5
5499 echo "$as_me: error: Invalid setting for --enable-zlib. Use \"yes\" or \"no\"" >&2;}
5500 { (exit 1); exit 1; }; } ;;
5501 esac
5502
5503 cat >>confdefs.h <<_ACEOF
5504 #define LLVM_ENABLE_ZLIB $LLVM_ENABLE_ZLIB
5505 _ACEOF
5506
5507
54805508 # Check whether --enable-pic was given.
54815509 if test "${enable_pic+set}" = set; then
54825510 enableval=$enable_pic;
1049710525 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1049810526 lt_status=$lt_dlunknown
1049910527 cat > conftest.$ac_ext <
10500 #line 10501 "configure"
10528 #line 10529 "configure"
1050110529 #include "confdefs.h"
1050210530
1050310531 #if HAVE_DLFCN_H
1344013468
1344113469 fi
1344213470
13471 if test "$LLVM_ENABLE_ZLIB" -eq 1 ; then
13472
13473 { echo "$as_me:$LINENO: checking for compress2 in -lz" >&5
13474 echo $ECHO_N "checking for compress2 in -lz... $ECHO_C" >&6; }
13475 if test "${ac_cv_lib_z_compress2+set}" = set; then
13476 echo $ECHO_N "(cached) $ECHO_C" >&6
13477 else
13478 ac_check_lib_save_LIBS=$LIBS
13479 LIBS="-lz $LIBS"
13480 cat >conftest.$ac_ext <<_ACEOF
13481 /* confdefs.h. */
13482 _ACEOF
13483 cat confdefs.h >>conftest.$ac_ext
13484 cat >>conftest.$ac_ext <<_ACEOF
13485 /* end confdefs.h. */
13486
13487 /* Override any GCC internal prototype to avoid an error.
13488 Use char because int might match the return type of a GCC
13489 builtin and then its argument prototype would still apply. */
13490 #ifdef __cplusplus
13491 extern "C"
13492 #endif
13493 char compress2 ();
13494 int
13495 main ()
13496 {
13497 return compress2 ();
13498 ;
13499 return 0;
13500 }
13501 _ACEOF
13502 rm -f conftest.$ac_objext conftest$ac_exeext
13503 if { (ac_try="$ac_link"
13504 case "(($ac_try" in
13505 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
13506 *) ac_try_echo=$ac_try;;
13507 esac
13508 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
13509 (eval "$ac_link") 2>conftest.er1
13510 ac_status=$?
13511 grep -v '^ *+' conftest.er1 >conftest.err
13512 rm -f conftest.er1
13513 cat conftest.err >&5
13514 echo "$as_me:$LINENO: \$? = $ac_status" >&5
13515 (exit $ac_status); } &&
13516 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
13517 { (case "(($ac_try" in
13518 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
13519 *) ac_try_echo=$ac_try;;
13520 esac
13521 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
13522 (eval "$ac_try") 2>&5
13523 ac_status=$?
13524 echo "$as_me:$LINENO: \$? = $ac_status" >&5
13525 (exit $ac_status); }; } &&
13526 { ac_try='test -s conftest$ac_exeext'
13527 { (case "(($ac_try" in
13528 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
13529 *) ac_try_echo=$ac_try;;
13530 esac
13531 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
13532 (eval "$ac_try") 2>&5
13533 ac_status=$?
13534 echo "$as_me:$LINENO: \$? = $ac_status" >&5
13535 (exit $ac_status); }; }; then
13536 ac_cv_lib_z_compress2=yes
13537 else
13538 echo "$as_me: failed program was:" >&5
13539 sed 's/^/| /' conftest.$ac_ext >&5
13540
13541 ac_cv_lib_z_compress2=no
13542 fi
13543
13544 rm -f core conftest.err conftest.$ac_objext \
13545 conftest$ac_exeext conftest.$ac_ext
13546 LIBS=$ac_check_lib_save_LIBS
13547 fi
13548 { echo "$as_me:$LINENO: result: $ac_cv_lib_z_compress2" >&5
13549 echo "${ECHO_T}$ac_cv_lib_z_compress2" >&6; }
13550 if test $ac_cv_lib_z_compress2 = yes; then
13551 cat >>confdefs.h <<_ACEOF
13552 #define HAVE_LIBZ 1
13553 _ACEOF
13554
13555 LIBS="-lz $LIBS"
13556
13557 fi
13558
13559 fi
13560
1344313561
1344413562 # Check whether --with-udis86 was given.
1344513563 if test "${with_udis86+set}" = set; then
1629216410
1629316411 else
1629416412 HAVE_PTHREAD=0
16413
16414 fi
16415 if test "$LLVM_ENABLE_ZLIB" -eq 1 ; then
16416
16417 for ac_header in zlib.h
16418 do
16419 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
16420 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
16421 { echo "$as_me:$LINENO: checking for $ac_header" >&5
16422 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
16423 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
16424 echo $ECHO_N "(cached) $ECHO_C" >&6
16425 fi
16426 ac_res=`eval echo '${'$as_ac_Header'}'`
16427 { echo "$as_me:$LINENO: result: $ac_res" >&5
16428 echo "${ECHO_T}$ac_res" >&6; }
16429 else
16430 # Is the header compilable?
16431 { echo "$as_me:$LINENO: checking $ac_header usability" >&5
16432 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
16433 cat >conftest.$ac_ext <<_ACEOF
16434 /* confdefs.h. */
16435 _ACEOF
16436 cat confdefs.h >>conftest.$ac_ext
16437 cat >>conftest.$ac_ext <<_ACEOF
16438 /* end confdefs.h. */
16439 $ac_includes_default
16440 #include <$ac_header>
16441 _ACEOF
16442 rm -f conftest.$ac_objext
16443 if { (ac_try="$ac_compile"
16444 case "(($ac_try" in
16445 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
16446 *) ac_try_echo=$ac_try;;
16447 esac
16448 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
16449 (eval "$ac_compile") 2>conftest.er1
16450 ac_status=$?
16451 grep -v '^ *+' conftest.er1 >conftest.err
16452 rm -f conftest.er1
16453 cat conftest.err >&5
16454 echo "$as_me:$LINENO: \$? = $ac_status" >&5
16455 (exit $ac_status); } &&
16456 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
16457 { (case "(($ac_try" in
16458 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
16459 *) ac_try_echo=$ac_try;;
16460 esac
16461 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
16462 (eval "$ac_try") 2>&5
16463 ac_status=$?
16464 echo "$as_me:$LINENO: \$? = $ac_status" >&5
16465 (exit $ac_status); }; } &&
16466 { ac_try='test -s conftest.$ac_objext'
16467 { (case "(($ac_try" in
16468 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
16469 *) ac_try_echo=$ac_try;;
16470 esac
16471 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
16472 (eval "$ac_try") 2>&5
16473 ac_status=$?
16474 echo "$as_me:$LINENO: \$? = $ac_status" >&5
16475 (exit $ac_status); }; }; then
16476 ac_header_compiler=yes
16477 else
16478 echo "$as_me: failed program was:" >&5
16479 sed 's/^/| /' conftest.$ac_ext >&5
16480
16481 ac_header_compiler=no
16482 fi
16483
16484 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
16485 { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
16486 echo "${ECHO_T}$ac_header_compiler" >&6; }
16487
16488 # Is the header present?
16489 { echo "$as_me:$LINENO: checking $ac_header presence" >&5
16490 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
16491 cat >conftest.$ac_ext <<_ACEOF
16492 /* confdefs.h. */
16493 _ACEOF
16494 cat confdefs.h >>conftest.$ac_ext
16495 cat >>conftest.$ac_ext <<_ACEOF
16496 /* end confdefs.h. */
16497 #include <$ac_header>
16498 _ACEOF
16499 if { (ac_try="$ac_cpp conftest.$ac_ext"
16500 case "(($ac_try" in
16501 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
16502 *) ac_try_echo=$ac_try;;
16503 esac
16504 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
16505 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
16506 ac_status=$?
16507 grep -v '^ *+' conftest.er1 >conftest.err
16508 rm -f conftest.er1
16509 cat conftest.err >&5
16510 echo "$as_me:$LINENO: \$? = $ac_status" >&5
16511 (exit $ac_status); } >/dev/null; then
16512 if test -s conftest.err; then
16513 ac_cpp_err=$ac_c_preproc_warn_flag
16514 ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
16515 else
16516 ac_cpp_err=
16517 fi
16518 else
16519 ac_cpp_err=yes
16520 fi
16521 if test -z "$ac_cpp_err"; then
16522 ac_header_preproc=yes
16523 else
16524 echo "$as_me: failed program was:" >&5
16525 sed 's/^/| /' conftest.$ac_ext >&5
16526
16527 ac_header_preproc=no
16528 fi
16529
16530 rm -f conftest.err conftest.$ac_ext
16531 { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
16532 echo "${ECHO_T}$ac_header_preproc" >&6; }
16533
16534 # So? What about this header?
16535 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
16536 yes:no: )
16537 { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
16538 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
16539 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
16540 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
16541 ac_header_preproc=yes
16542 ;;
16543 no:yes:* )
16544 { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
16545 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
16546 { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
16547 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
16548 { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
16549 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
16550 { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
16551 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
16552 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
16553 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
16554 { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
16555 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
16556 ( cat <<\_ASBOX
16557 ## ------------------------------------ ##
16558 ## Report this to http://llvm.org/bugs/ ##
16559 ## ------------------------------------ ##
16560 _ASBOX
16561 ) | sed "s/^/$as_me: WARNING: /" >&2
16562 ;;
16563 esac
16564 { echo "$as_me:$LINENO: checking for $ac_header" >&5
16565 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
16566 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
16567 echo $ECHO_N "(cached) $ECHO_C" >&6
16568 else
16569 eval "$as_ac_Header=\$ac_header_preproc"
16570 fi
16571 ac_res=`eval echo '${'$as_ac_Header'}'`
16572 { echo "$as_me:$LINENO: result: $ac_res" >&5
16573 echo "${ECHO_T}$ac_res" >&6; }
16574
16575 fi
16576 if test `eval echo '${'$as_ac_Header'}'` = yes; then
16577 cat >>confdefs.h <<_ACEOF
16578 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
16579 _ACEOF
16580 HAVE_LIBZ=1
16581
16582 else
16583 HAVE_LIBZ=0
16584
16585 fi
16586
16587 done
16588
16589 else
16590 HAVE_LIBZ=0
1629516591
1629616592 fi
1629716593
2269122987 ENABLE_DOXYGEN!$ENABLE_DOXYGEN$ac_delim
2269222988 LLVM_ENABLE_THREADS!$LLVM_ENABLE_THREADS$ac_delim
2269322989 ENABLE_PTHREADS!$ENABLE_PTHREADS$ac_delim
22990 LLVM_ENABLE_ZLIB!$LLVM_ENABLE_ZLIB$ac_delim
2269422991 ENABLE_PIC!$ENABLE_PIC$ac_delim
2269522992 ENABLE_SHARED!$ENABLE_SHARED$ac_delim
2269622993 ENABLE_EMBED_STDCXX!$ENABLE_EMBED_STDCXX$ac_delim
2276523062 LIBXML2_LIBS!$LIBXML2_LIBS$ac_delim
2276623063 LIBXML2_INC!$LIBXML2_INC$ac_delim
2276723064 HAVE_PTHREAD!$HAVE_PTHREAD$ac_delim
23065 HAVE_LIBZ!$HAVE_LIBZ$ac_delim
2276823066 HUGE_VAL_SANITY!$HUGE_VAL_SANITY$ac_delim
2276923067 MMAP_FILE!$MMAP_FILE$ac_delim
2277023068 SHLIBEXT!$SHLIBEXT$ac_delim
2278223080 BINDINGS_TO_BUILD!$BINDINGS_TO_BUILD$ac_delim
2278323081 ALL_BINDINGS!$ALL_BINDINGS$ac_delim
2278423082 OCAML_LIBDIR!$OCAML_LIBDIR$ac_delim
22785 ENABLE_VISIBILITY_INLINES_HIDDEN!$ENABLE_VISIBILITY_INLINES_HIDDEN$ac_delim
22786 RPATH!$RPATH$ac_delim
2278723083 _ACEOF
2278823084
2278923085 if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
2282523121 ac_delim='%!_!# '
2282623122 for ac_last_try in false false false false false :; do
2282723123 cat >conf$$subs.sed <<_ACEOF
23124 ENABLE_VISIBILITY_INLINES_HIDDEN!$ENABLE_VISIBILITY_INLINES_HIDDEN$ac_delim
23125 RPATH!$RPATH$ac_delim
2282823126 RDYNAMIC!$RDYNAMIC$ac_delim
2282923127 program_prefix!$program_prefix$ac_delim
2283023128 LIBOBJS!$LIBOBJS$ac_delim
2283123129 LTLIBOBJS!$LTLIBOBJS$ac_delim
2283223130 _ACEOF
2283323131
22834 if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 4; then
23132 if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 6; then
2283523133 break
2283623134 elif $ac_last_try; then
2283723135 { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
269269
270270 **LLVM_USE_INTEL_JITEVENTS**:BOOL
271271 Enable building support for Intel JIT Events API. Defaults to OFF
272
273 **LLVM_ENABLE_ZLIB**:BOOL
274 Build with zlib to support compression/uncompression in LLVM tools.
275 Defaults to ON.
272276
273277 Executing the test suite
274278 ========================
228228 +--------------------------------------------------------------+-----------------+---------------------------------------------+
229229 | `libtool `_ | 1.5.22 | Shared library manager\ :sup:`4` |
230230 +--------------------------------------------------------------+-----------------+---------------------------------------------+
231 | `zlib `_ | >=1.2.3.4 | Compression library\ :sup:`5` |
232 +--------------------------------------------------------------+-----------------+---------------------------------------------+
231233
232234 .. note::
233235
242244 #. If you want to make changes to the configure scripts, you will need GNU
243245 autoconf (2.60), and consequently, GNU M4 (version 1.4 or higher). You
244246 will also need automake (1.9.6). We only use aclocal from that package.
247 #. Optional, adds compression/uncompression capabilities to selected LLVM
248 tools.
245249
246250 Additionally, your compilation host is expected to have the usual plethora of
247251 Unix utilities. Specifically:
497497 /* Define if the xdot.py program is available */
498498 #cmakedefine HAVE_XDOT_PY ${HAVE_XDOT_PY}
499499
500 /* Define to 1 if you have the header file. */
501 #cmakedefine HAVE_ZLIB_H ${HAVE_ZLIB_H}
502
500503 /* Have host's _alloca */
501504 #cmakedefine HAVE__ALLOCA ${HAVE__ALLOCA}
502505
568571
569572 /* Define if threads enabled */
570573 #cmakedefine01 LLVM_ENABLE_THREADS
574
575 /* Define if zlib compression is available */
576 #cmakedefine01 LLVM_ENABLE_ZLIB
571577
572578 /* Installation directory for config files */
573579 #cmakedefine LLVM_ETCDIR "${LLVM_ETCDIR}"
225225 /* Define to 1 if you have the `udis86' library (-ludis86). */
226226 #undef HAVE_LIBUDIS86
227227
228 /* Define to 1 if you have the `z' library (-lz). */
229 #undef HAVE_LIBZ
230
228231 /* Define to 1 if you have the header file. */
229232 #undef HAVE_LIMITS_H
230233
502505 /* Define if the xdot.py program is available */
503506 #undef HAVE_XDOT_PY
504507
508 /* Define to 1 if you have the header file. */
509 #undef HAVE_ZLIB_H
510
505511 /* Have host's _alloca */
506512 #undef HAVE__ALLOCA
507513
573579
574580 /* Define if threads enabled */
575581 #undef LLVM_ENABLE_THREADS
582
583 /* Define if zlib is enabled */
584 #undef LLVM_ENABLE_ZLIB
576585
577586 /* Installation directory for config files */
578587 #undef LLVM_ETCDIR
0 //===-- llvm/Support/Compression.h ---Compression----------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains basic functions for compression/uncompression.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #ifndef LLVM_SUPPORT_COMPRESSION_H
14 #define LLVM_SUPPORT_COMPRESSION_H
15
16 #include "llvm/Support/DataTypes.h"
17
18 namespace llvm {
19
20 class MemoryBuffer;
21 template class OwningPtr;
22 class StringRef;
23
24 namespace zlib {
25
26 enum CompressionLevel {
27 NoCompression,
28 DefaultCompression,
29 BestSpeedCompression,
30 BestSizeCompression
31 };
32
33 enum Status {
34 StatusOK,
35 StatusUnsupported, // zlib is unavaliable
36 StatusOutOfMemory, // there was not enough memory
37 StatusBufferTooShort, // there was not enough room in the output buffer
38 StatusInvalidArg, // invalid input parameter
39 StatusInvalidData // data was corrupted or incomplete
40 };
41
42 bool isAvailable();
43
44 Status compress(StringRef InputBuffer,
45 OwningPtr &CompressedBuffer,
46 CompressionLevel Level = DefaultCompression);
47
48 Status uncompress(StringRef InputBuffer,
49 OwningPtr &UncompressedBuffer,
50 size_t UncompressedSize);
51
52 } // End of namespace zlib
53
54 } // End of namespace llvm
55
56 #endif
57
66 BranchProbability.cpp
77 circular_raw_ostream.cpp
88 CommandLine.cpp
9 Compression.cpp
910 ConstantRange.cpp
1011 ConvertUTF.c
1112 ConvertUTFWrapper.cpp
0 //===--- Compression.cpp - Compression implementation ---------------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements compression functions.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #include "llvm/Support/Compression.h"
14 #include "llvm/ADT/OwningPtr.h"
15 #include "llvm/ADT/StringRef.h"
16 #include "llvm/Config/config.h"
17 #include "llvm/Support/ErrorHandling.h"
18 #include "llvm/Support/MemoryBuffer.h"
19 #if LLVM_ENABLE_ZLIB == 1 && HAVE_ZLIB_H
20 #include
21 #endif
22
23 using namespace llvm;
24
25 #if LLVM_ENABLE_ZLIB == 1
26 static int encodeZlibCompressionLevel(zlib::CompressionLevel Level) {
27 switch (Level) {
28 case zlib::NoCompression: return 0;
29 case zlib::BestSpeedCompression: return 1;
30 case zlib::DefaultCompression: return Z_DEFAULT_COMPRESSION;
31 case zlib::BestSizeCompression: return 9;
32 }
33 }
34
35 static zlib::Status encodeZlibReturnValue(int ReturnValue) {
36 switch (ReturnValue) {
37 case Z_OK: return zlib::StatusOK;
38 case Z_MEM_ERROR: return zlib::StatusOutOfMemory;
39 case Z_BUF_ERROR: return zlib::StatusBufferTooShort;
40 case Z_STREAM_ERROR: return zlib::StatusInvalidArg;
41 case Z_DATA_ERROR: return zlib::StatusInvalidData;
42 default: llvm_unreachable("unknown zlib return status!");
43 }
44 }
45
46 bool zlib::isAvailable() { return true; }
47 zlib::Status zlib::compress(StringRef InputBuffer,
48 OwningPtr &CompressedBuffer,
49 CompressionLevel Level) {
50 unsigned long CompressedSize = ::compressBound(InputBuffer.size());
51 OwningArrayPtr TmpBuffer(new char[CompressedSize]);
52 int CLevel = encodeZlibCompressionLevel(Level);
53 Status Res = encodeZlibReturnValue(::compress2(
54 (Bytef *)TmpBuffer.get(), &CompressedSize,
55 (const Bytef *)InputBuffer.data(), InputBuffer.size(), CLevel));
56 if (Res == StatusOK)
57 CompressedBuffer.reset(MemoryBuffer::getMemBufferCopy(
58 StringRef(TmpBuffer.get(), CompressedSize)));
59 return Res;
60 }
61
62 zlib::Status zlib::uncompress(StringRef InputBuffer,
63 OwningPtr &UncompressedBuffer,
64 size_t UncompressedSize) {
65 OwningArrayPtr TmpBuffer(new char[UncompressedSize]);
66 Status Res = encodeZlibReturnValue(
67 ::uncompress((Bytef *)TmpBuffer.get(), (uLongf *)&UncompressedSize,
68 (const Bytef *)InputBuffer.data(), InputBuffer.size()));
69 if (Res == StatusOK)
70 UncompressedBuffer.reset(MemoryBuffer::getMemBufferCopy(
71 StringRef(TmpBuffer.get(), UncompressedSize)));
72 return Res;
73 }
74
75 #else
76 bool zlib::isAvailable() { return false; }
77 zlib::Status zlib::compress(StringRef InputBuffer,
78 OwningPtr &CompressedBuffer,
79 CompressionLevel Level) {
80 return zlib::StatusUnsupported;
81 }
82 zlib::Status zlib::uncompress(StringRef InputBuffer,
83 OwningPtr &UncompressedBuffer,
84 size_t UncompressedSize) {
85 return zlib::StatusUnsupported;
86 }
87 #endif
88
99 BlockFrequencyTest.cpp
1010 Casting.cpp
1111 CommandLineTest.cpp
12 CompressionTest.cpp
1213 ConstantRangeTest.cpp
1314 DataExtractorTest.cpp
1415 EndianTest.cpp
0 //===- llvm/unittest/Support/CompressionTest.cpp - Compression tests ------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements unit tests for the Compression functions.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #include "llvm/Support/Compression.h"
14 #include "llvm/ADT/OwningPtr.h"
15 #include "llvm/ADT/StringRef.h"
16 #include "llvm/Config/config.h"
17 #include "llvm/Support/MemoryBuffer.h"
18 #include "gtest/gtest.h"
19
20 using namespace llvm;
21
22 namespace {
23
24 #if LLVM_ENABLE_ZLIB == 1
25
26 void TestZlibCompression(StringRef Input, zlib::CompressionLevel Level) {
27 OwningPtr Compressed;
28 OwningPtr Uncompressed;
29 EXPECT_EQ(zlib::StatusOK, zlib::compress(Input, Compressed, Level));
30 // Check that uncompressed buffer is the same as original.
31 EXPECT_EQ(zlib::StatusOK, zlib::uncompress(Compressed->getBuffer(),
32 Uncompressed, Input.size()));
33 EXPECT_EQ(Input.size(), Uncompressed->getBufferSize());
34 EXPECT_EQ(0,
35 memcmp(Input.data(), Uncompressed->getBufferStart(), Input.size()));
36 if (Input.size() > 0) {
37 // Uncompression fails if expected length is too short.
38 EXPECT_EQ(zlib::StatusBufferTooShort,
39 zlib::uncompress(Compressed->getBuffer(), Uncompressed,
40 Input.size() - 1));
41 }
42 }
43
44 TEST(CompressionTest, Zlib) {
45 TestZlibCompression("", zlib::DefaultCompression);
46
47 TestZlibCompression("hello, world!", zlib::NoCompression);
48 TestZlibCompression("hello, world!", zlib::BestSizeCompression);
49 TestZlibCompression("hello, world!", zlib::BestSpeedCompression);
50 TestZlibCompression("hello, world!", zlib::DefaultCompression);
51
52 const size_t kSize = 1024;
53 char BinaryData[kSize];
54 for (size_t i = 0; i < kSize; ++i) {
55 BinaryData[i] = i & 255;
56 }
57 StringRef BinaryDataStr(BinaryData, kSize);
58
59 TestZlibCompression(BinaryDataStr, zlib::NoCompression);
60 TestZlibCompression(BinaryDataStr, zlib::BestSizeCompression);
61 TestZlibCompression(BinaryDataStr, zlib::BestSpeedCompression);
62 TestZlibCompression(BinaryDataStr, zlib::DefaultCompression);
63 }
64
65 #endif
66
67 }