Skip to content

Commit

Permalink
re-enable clang
Browse files Browse the repository at this point in the history
  • Loading branch information
liquidaty authored Nov 12, 2022
1 parent 9813cca commit 058a990
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 306 deletions.
106 changes: 53 additions & 53 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
env:
TAG: "0.3.2"
AMD64_LINUX_GCC: amd64-linux-gcc
# AMD64_LINUX_CLANG: amd64-linux-clang
AMD64_LINUX_CLANG: amd64-linux-clang
AMD64_WINDOWS_MINGW: amd64-windows-mingw
AMD64_MACOSX_GCC: amd64-macosx-gcc
AMD64_FREEBSD_GCC: amd64-freebsd-gcc
Expand Down Expand Up @@ -98,18 +98,18 @@ jobs:
./scripts/ci-create-debian-package.sh
./scripts/ci-create-rpm-package.sh
# - name: Build on Linux (${{ env.AMD64_LINUX_CLANG }})
# if: runner.os == 'Linux'
# env:
# PREFIX: ${{ env.AMD64_LINUX_CLANG }}
# CC: clang
# MAKE: make
# RUN_TESTS: true
# shell: bash
# run: |
# ./scripts/ci-build.sh
# ./scripts/ci-create-debian-package.sh
# ./scripts/ci-create-rpm-package.sh
- name: Build on Linux (${{ env.AMD64_LINUX_CLANG }})
if: runner.os == 'Linux'
env:
PREFIX: ${{ env.AMD64_LINUX_CLANG }}
CC: clang
MAKE: make
RUN_TESTS: true
shell: bash
run: |
./scripts/ci-build.sh
./scripts/ci-create-debian-package.sh
./scripts/ci-create-rpm-package.sh
- name: Build on Linux (${{ env.AMD64_WINDOWS_MINGW }})
if: runner.os == 'Linux'
Expand Down Expand Up @@ -151,16 +151,16 @@ jobs:
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
if-no-files-found: error

# - name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.zip)
# if: runner.os == 'Linux'
# uses: actions/upload-artifact@v3
# env:
# ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.zip
# with:
# name: ${{ env.ARTIFACT_NAME }}
# path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}
# retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
# if-no-files-found: error
- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.zip)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.zip
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
if-no-files-found: error

- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_GCC }}.deb)
if: runner.os == 'Linux'
Expand All @@ -173,16 +173,16 @@ jobs:
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
if-no-files-found: error

# - name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.deb)
# if: runner.os == 'Linux'
# uses: actions/upload-artifact@v3
# env:
# ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.deb
# with:
# name: ${{ env.ARTIFACT_NAME }}
# path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}
# retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
# if-no-files-found: error
- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.deb)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.deb
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
if-no-files-found: error

- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_GCC }}.rpm)
if: runner.os == 'Linux'
Expand All @@ -195,16 +195,16 @@ jobs:
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
if-no-files-found: error

# - name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.rpm)
# if: runner.os == 'Linux'
# uses: actions/upload-artifact@v3
# env:
# ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.rpm
# with:
# name: ${{ env.ARTIFACT_NAME }}
# path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}
# retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
# if-no-files-found: error
- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.rpm)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.rpm
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
if-no-files-found: error

- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_WINDOWS_MINGW }}.zip)
if: runner.os == 'Linux'
Expand Down Expand Up @@ -261,16 +261,16 @@ jobs:
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
if-no-files-found: error

# - name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.tar.gz)
# if: runner.os == 'Linux'
# uses: actions/upload-artifact@v3
# env:
# ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.tar.gz
# with:
# name: ${{ env.ARTIFACT_NAME }}
# path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}
# retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
# if-no-files-found: error
- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.tar.gz)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
env:
ARTIFACT_NAME: zsv-${{ env.TAG }}-${{ env.AMD64_LINUX_CLANG }}.tar.gz
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_DIR }}/${{ env.ARTIFACT_NAME }}
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
if-no-files-found: error

- name: Upload (zsv-${{ env.TAG }}-${{ env.AMD64_WINDOWS_MINGW }}.tar.gz)
if: runner.os == 'Linux'
Expand Down
25 changes: 13 additions & 12 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ THIS_LIB_BASE=$(shell cd .. && pwd)
INCLUDE_DIR=${THIS_LIB_BASE}/include
BUILD_DIR=${THIS_LIB_BASE}/build/${BUILD_SUBDIR}/${CCBN}
UTILS1=writer file err signal mem clock arg dl string dirs prop cache jq
# LDFLAGS=

ZSV_EXTRAS ?=
ifneq ($(WIN),0)
Expand Down Expand Up @@ -201,14 +200,17 @@ YAJL_HELPER_INCLUDE=-I${THIS_MAKEFILE_DIR}/external/yajl_helper
JQ_TARBALL=${THIS_MAKEFILE_DIR}/external/jq-1.6.tar.bz2
JQ_SRC=${BUILD_DIR}/external/jq-src

JQ_PREFIX=
JQ_PREFIX ?=
ifeq ($(JQ_PREFIX),)
JQ_PREFIX=${BUILD_DIR}-external/jq-build
JQ_INCLUDE_DIR=${JQ_PREFIX}/include
JQ_BUNDLE_LIB=${JQ_PREFIX}/lib/libjq.a
JQ_LIB=${JQ_BUNDLE_LIB}
else
JQ_INCLUDE_DIR=${JQ_PREFIX}/include
JQ_LIB=
endif

JQ_INCLUDE_DIR=${JQ_PREFIX}/include
JQ_LIB=${JQ_PREFIX}/lib/libjq.a

## json writer
JSONWRITER_SRC=${THIS_MAKEFILE_DIR}/external/json_writer-1.0
JSONWRITER_INCLUDE=-I${THIS_MAKEFILE_DIR}/external/json_writer-1.0
Expand Down Expand Up @@ -286,7 +288,7 @@ ${CLEANS}: clean-%:
.SUFFIXES:
.SUFFIXES: .o .c .a

${BUILD_DIR}/objs/utils/%.o : utils/%.c ${INCLUDE_DIR}/zsv/utils/%.h ${JQ_INCLUDE_DIR}
${BUILD_DIR}/objs/utils/%.o : utils/%.c ${INCLUDE_DIR}/zsv/utils/%.h ${JQ_LIB}
@mkdir -p `dirname "$@"`
${CC} ${CFLAGS} -I${INCLUDE_DIR} -I${UTF8PROC_INCLUDE} -DINCLUDE_SRC -o $@ -c utils/$*.c ${MORE_SOURCE}

Expand All @@ -302,7 +304,7 @@ ${INIH_OBJECT}: ${INIH_SRC}/ini.c
@mkdir -p `dirname "$@"`
${CC} ${CFLAGS} -I${INIH_INCLUDE} -DINI_HANDLER_LINENO=1 -DINI_CALL_HANDLER_ON_NEW_SECTION=1 -c $< -o $@

${CLI_APP_OBJECT} : cli_ini.c builtin/*.c ${JQ_INCLUDE_DIR}
${CLI_APP_OBJECT} : cli_ini.c builtin/*.c ${JQ_LIB}
${CLI_APP_OBJECT} ${CLI_OBJECTS}: ${CLI_OBJ_PFX}%.o: %.c ${UTF8PROC_SRC}/utf8proc.c # ${MORE_OBJECTS}
@mkdir -p `dirname "$@"`
${CC} ${CFLAGS} -DVERSION=\"${VERSION}\" -DZSV_CLI ${CLI_INCLUDE} -I${THIS_MAKEFILE_DIR}/external/sglib -I${INCLUDE_DIR} -c $< -o $@ ${MORE_SOURCE}
Expand All @@ -312,8 +314,6 @@ ${CLI}: cli_internal.c.in cli_internal.h cli_internal.h.in ${CLI_APP_OBJECT} ${C
${CC} ${CFLAGS} ${CFLAGS_EXE} -I${INCLUDE_DIR} -o $@ ${CLI_APP_OBJECT} ${CLI_OBJECTS} ${OBJECTS} ${UTF8PROC_OBJECT} ${INIH_OBJECT} -L${LIBDIR} ${LIBZSV_L} ${LDFLAGS} ${LDFLAGS_OPT} ${MORE_OBJECTS} ${MORE_SOURCE} ${MORE_LIBS} ${STATIC_LIB_FLAGS}
@echo Built $@

# cli_internal: cli_internal.c.in cli_internal.h cli_internal.h.in

cli_internal.h.in: ${THIS_MAKEFILE_DIR}/../include/zsv/ext/implementation_private.h
cat $< | perl -ne 'print if /ZSV_EXT_EXPORT/ .. /;/' | sed 's/ZSV_EXT_EXPORT *//g' | sed $$'s/ *;.*/;\\\n/' | sed 's/(/)(/' | sed 's/zsv_ext_\([a-z]*\))/(*\1)/' | grep -v '^$$' > $@

Expand All @@ -322,7 +322,7 @@ cli_internal.c.in: cli_internal.h.in

${SQLITE_EXT}: ${SQLITE_SRC}

${JQ_INCLUDE_DIR}: ${JQ_LIB}
# ${JQ_INCLUDE_DIR}: ${JQ_LIB}

${JQ_SRC}: ${JQ_TARBALL}
@rm -rf $@-tmp
Expand All @@ -337,12 +337,13 @@ ${JQ_SRC}: ${JQ_TARBALL}
lib-jq: ${JQ_LIB}
@echo "Using jq library ${JQ_LIB}"

${JQ_LIB}: ${JQ_SRC} ${JQ_INCLUDE_DIR}
${JQ_BUNDLE_LIB}: ${JQ_SRC} # -D_REENTRANT needed for clang to not break
cd ${JQ_SRC} \
&& CC="${CC}" CFLAGS="${CFLAGS}" ./configure \
&& CC="${CC}" CFLAGS="${CFLAGS} -D_REENTRANT" ./configure \
--prefix="${JQ_PREFIX}" \
--disable-maintainer-mode \
--without-oniguruma \
--no-recursion \
--disable-docs \
--disable-shared \
--enable-static \
Expand Down
58 changes: 24 additions & 34 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,16 @@ for arg ; do
case "$arg" in
--help|-h) usage ;;
--host=*) host=${arg#*=} ;;

--arch=*) ARCH=${arg#*=} ;;
ARCH=*) ARCH=${arg#*=} ;;

--config-file=*) CONFIGFILE=${arg#*=} ;;
CONFIGFILE=*) CONFIGFILE=${arg#*=} ;;

--jq-prefix=*) JQ_PREFIX=${arg#*=} ;;
JQ_PREFIX=*) JQ_PREFIX=${arg#*=} ;;

--prefix=*) ;; # already handled
--exec-prefix=*) ;; # already handled EXEC_PREFIX=${arg#*=} ;;
--docdir=*) DOCDIR=${arg#*=} ;;
Expand Down Expand Up @@ -410,8 +416,8 @@ CCSEARCHPATH=$(echo | ${CC} -E -Wp,-v - 2>&1 | ${AWK} '/ \//{print substr($0,2);
# Check if it is clang, and the llvm tools instead
compiler=$(${CC} -v 2>&1 | ${AWK} '/ +version +/{for(i=1;i<=NF;i++){if($i=="version"){printf("%s\n",(last=="LLVM")?"clang":last);exit 0;}last=$i;}}')
if test "$compiler" = "clang"; then
arlist="$CC-llvm-ar $host-llvm-ar $CC-ar $host-ar llvm-ar `ls /usr/bin/llvm-ar*` ar"
ranliblist="$CC-llvm-ranlib $host-llvm-ranlib $CC-ranlib $host-ranlib llvm-ranlib `ls /usr/bin/llvm-ranlib*` ranlib"
arlist="$CC-llvm-ar $host-llvm-ar $CC-ar $host-ar llvm-ar `ls /usr/bin/llvm-ar* 2>/dev/null` ar"
ranliblist="$CC-llvm-ranlib $host-llvm-ranlib $CC-ranlib $host-ranlib llvm-ranlib `ls /usr/bin/llvm-ranlib* 2>/dev/null` ranlib"
else
arlist="$CC-ar $host-$compiler-ar $host-ar $compiler-ar ar"
ranliblist="$CC-ranlib $host-$compiler-ranlib $host-ranlib $compiler-ranlib $compiler-ranlib ranlib"
Expand Down Expand Up @@ -504,14 +510,6 @@ test "$usepic" = "no" && tryflag CFLAGS_PIC -fno-pic
test "$usepie" = "no" && tryldflag LDFLAGS_PIE -no-pie
test "$usepic" = "no" && trysharedldflag LDFLAGS_PIC -fno-pic

#if test $MINGW -eq 0 ; then
#LDFLAGS_STD="-lc"
#tryflag CFLAGS_AUTO -fstack-protector-all
#case "$CFLAGS_AUTO" in
#*-fstack-protector*) CFLAGS_AUTO="-D_FORTIFY_SOURCE=2"; ;;
#esac
#fi

tryflag CFLAGS -pipe

# Try flags to optimize speed
Expand Down Expand Up @@ -594,17 +592,6 @@ if [ "$TRY_AVX512" = "yes" ]; then
fi
fi

#if [ "$HAVE_AVX256" != "1" ]; then
# tryccfn CFLAGS_AVX_256 "_mm256_movemask_epi8" "immintrin.h" && trycchdr CFLAGS_AVX_256 "immintrin.h" && ( tryccfn CFLAGS_AVX_256 "_blsr_u32" "immintrin.h" || tryccfn CFLAGS_AVX_256 "__blsr_u32" "immintrin.h" ) && HAVE_AVX256=1
# fi

#if [ "$HAVE_AVX256" = "1" ] && [ "$CFLAGS_AVX" != "-mavx2" ] ; then
# echo "AVX256 requested, but -mavx2 compiler flag not supported"
# exit 1
#elif [ "$HAVE_AVX256" != "1" ]; then
# CFLAGS_AVX=
#fi

tryccfn CFLAGS_AUTO "memmem" "string.h"

if [ "$usetermcap" = "yes" ] || [ "$usetermcap" = "auto" ] ; then
Expand All @@ -615,20 +602,23 @@ if [ "$usetermcap" = "yes" ] || [ "$usetermcap" = "auto" ] ; then
fi
fi

# if [ "$usejq" = "yes" ] || [ "$usejq" = "auto" ] ; then
# tryldflag LDFLAGS_JQ -ljq -L${PREFIX}/lib || \
# if test "$usejq" = "yes"; then
# echo "Error: --enable-jq specified, but not found"
# exit 1
# fi
if [ "$JQ_PREFIX" != "" ] && [ "$ARCH" = "native" ]; then
echo "checking --prefix-jq ${JQ_PREFIX}"
if ! tryldflag LDFLAGS_JQ -ljq -L${JQ_PREFIX}/lib ; then
echo "Error: Failed to compile with -ljq and -L${JQ_PREFIX}/lib"
exit 1
else
LDFLAGS_JQ="$LDFLAGS_JQ -L$JQ_PREFIX/lib"
fi
fi

tryldflag LDFLAGS_JQ -lm
tryldflag LDFLAGS_JQ -lshlwapi
if [ "$MINGW" = "1" ]; then
tryldflag LDFLAGS_TMP -pthread && STATIC_LIBS="$STATIC_LIBS -pthread"
else
tryldflag LDFLAGS_JQ -pthread
fi
# fi

tryccfn CFLAGS_AUTO "arc4random_uniform" "stdlib.h" || tryccfn CFLAGS_AUTO "rand_s" "stdlib.h" "" "#define _CRT_RAND_S"
tryccfn1 CFLAGS_AUTO "__builtin_expect" "0,0"
Expand Down Expand Up @@ -678,6 +668,7 @@ LDFLAGS_STD = $LDFLAGS_STD
CFLAGS_OPT = $CFLAGS_OPT
LDFLAGS_OPT = $LDFLAGS_OPT
LDFLAGS_TERMCAP = $LDFLAGS_TERMCAP
JQ_PREFIX = $JQ_PREFIX
LDFLAGS_JQ = $LDFLAGS_JQ
STATIC_LIBS = $STATIC_LIBS
CFLAGS_AUTO = $CFLAGS_AUTO
Expand Down Expand Up @@ -715,16 +706,15 @@ echo ""
echo "****************************************************************"
echo "* zsv configuration *"
echo "****************************************************************"
# if [ "$LDFLAGS_JQ" = "" ]; then
# echo "* - libjq (-ljq): no. \`jq\` command will be disabled *"
# else
# echo "* - libjq: yes *"
# fi

if [ "$JQ_PREFIX" != "" ]; then
echo "* - jq-prefix: $JQ_PREFIX *"
fi

if [ "$LDFLAGS_TERMCAP" = "" ]; then
echo "* - termcap: no. \`pretty\` will use default width assumption *"
else
echo "* - termcap: yes *"
echo "* - termcap: yes *"
fi

if [ "$HAVE_AVX512" = "1" ]; then
Expand Down
2 changes: 0 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ ifeq ($(NO_UTF8_CHECK),1)
endif


# CFLAGS+= -Dfwrite=zsv_fwrite_clock -Dfflush=zsv_fflush_clock -Dfread=zsv_fread_clock

help:
@echo "${MAKE} [CONFIGFILE=config.mk] [NO_UTF8_CHECK=1] [VERBOSE=1] [LIBDIR=${LIBDIR}] [INCLUDEDIR=${INCLUDEDIR}] [LIB_SUFFIX=]"

Expand Down
Loading

0 comments on commit 058a990

Please sign in to comment.