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

lack src/parser.c when bulid in sub directory #2549

Closed
goodpaperman opened this issue Mar 3, 2023 · 5 comments
Closed

lack src/parser.c when bulid in sub directory #2549

goodpaperman opened this issue Mar 3, 2023 · 5 comments
Labels

Comments

@goodpaperman
Copy link

goodpaperman commented Mar 3, 2023

Describe the bug
I was using following script to do cross-compile build:

#! /bin/sh

git clone https://github.com/stedolan/jq.git
cd jq

mkdir build
cd build

autoreconf -i ..
CPATH="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/"
../configure --without-oniguruma --disable-maintainer-mode  CFLAGS='-std=c99' --prefix=$PWD/install/ --host='armv7a-linux-androideabi21' CC="$CPATH/armv7a-linux-androideabi21-clang"  LD="$CPATH/arm-linux-androideabi-ld"  AR="$CPATH/arm-linux-androideabi-ar"

make
make install

but make complains about lack of src/parser.c:

$ make
...
  CC       src/lexer.lo
  YACC     src/parser.c
NOT building parser.c!
  CC       src/parser.lo
clang: error: no such file or directory: 'src/parser.c'
clang: error: no input files
make[2]: *** [src/parser.lo] Error 1
make[2]: Leaving directory `/home/users/yunhai01/test/jq/build'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/users/yunhai01/test/jq/build'
make: *** [all] Error 2
make  install-recursive
make[1]: Entering directory `/home/users/yunhai01/test/jq/build'
make[2]: Entering directory `/home/users/yunhai01/test/jq/build'
  YACC     src/parser.c
NOT building parser.c!
  CC       src/parser.lo
clang: error: no such file or directory: 'src/parser.c'
clang: error: no input files
make[2]: *** [src/parser.lo] Error 1
make[2]: Leaving directory `/home/users/yunhai01/test/jq/build'
make[1]: *** [install-recursive] Error 1
make[1]: Leaving directory `/home/users/yunhai01/test/jq/build'
make: *** [install] Error 2

I find there is a parser.c in ../src but not in src, because I make a directory build to contain all intermediate files.
after cp ../src/parser.c src/ it works, so I think yacc don't put the output in right place:

$ make
make  all-recursive
make[1]: Entering directory `/home/users/yunhai01/test/jq/build'
make[2]: Entering directory `/home/users/yunhai01/test/jq/build'
  CC       src/parser.lo
  CCLD     libjq.la
  CC       src/main.o
  CCLD     jq
make[2]: Leaving directory `/home/users/yunhai01/test/jq/build'
make[1]: Leaving directory `/home/users/yunhai01/test/jq/build'

To Reproduce
following my step, even not cross-compile can reproduce the problem

Expected behavior
make success

Environment (please complete the following information):

  • Linux yunhai.bcc-bdbl.baidu.com 3.10.0-1160.21.1.el7.x86_64 STDIN as implicit array #1 SMP Tue Mar 16 18:28:22 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
  • jq-1.6-159-gcff5336-dirty

Additional context
make directly in the src is ok, I tried that.

@itchyny itchyny added the build label Jun 3, 2023
@itchyny itchyny added this to the 1.7 release milestone Jun 25, 2023
@itchyny
Copy link
Contributor

itchyny commented Jun 28, 2023

I cannot reproduce this issue. Am I missing something or already fixed?

log
 $ cd $(mktemp -d)
 $ git clone --depth=1 https://github.com/jqlang/jq.git
Cloning into 'jq'...
remote: Enumerating objects: 264, done.
remote: Counting objects: 100% (264/264), done.
remote: Compressing objects: 100% (217/217), done.
remote: Total 264 (delta 19), reused 172 (delta 13), pack-reused 0
Receiving objects: 100% (264/264), 1.09 MiB | 5.77 MiB/s, done.
Resolving deltas: 100% (19/19), done.

 $ cd jq
 $ mkdir -p build
 $ cd build

 $ autoreconf -i ..
glibtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, 'config'.
glibtoolize: copying file 'config/ltmain.sh'
glibtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'config/m4'.
glibtoolize: copying file 'config/m4/libtool.m4'
glibtoolize: copying file 'config/m4/ltoptions.m4'
glibtoolize: copying file 'config/m4/ltsugar.m4'
glibtoolize: copying file 'config/m4/ltversion.m4'
glibtoolize: copying file 'config/m4/lt~obsolete.m4'
configure.ac:14: warning: The macro `AC_PROG_CC_STDC' is obsolete.
configure.ac:14: You should run autoupdate.
./lib/autoconf/c.m4:1666: AC_PROG_CC_STDC is expanded from...
configure.ac:14: the top level
configure.ac:19: warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
./lib/autoconf/specific.m4:364: AC_USE_SYSTEM_EXTENSIONS is expanded from...
configure.ac:19: the top level
configure.ac:59: warning: The macro `AC_HELP_STRING' is obsolete.
configure.ac:59: You should run autoupdate.
./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from...
configure.ac:59: the top level
configure.ac:64: warning: The macro `AC_HELP_STRING' is obsolete.
configure.ac:64: You should run autoupdate.
./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from...
configure.ac:64: the top level
configure.ac:68: warning: The macro `AC_HELP_STRING' is obsolete.
configure.ac:68: You should run autoupdate.
./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from...
configure.ac:68: the top level
configure.ac:72: warning: The macro `AC_HELP_STRING' is obsolete.
configure.ac:72: You should run autoupdate.
./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from...
configure.ac:72: the top level
configure.ac:76: warning: The macro `AC_HELP_STRING' is obsolete.
configure.ac:76: You should run autoupdate.
./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from...
configure.ac:76: the top level
configure.ac:80: warning: The macro `AC_HELP_STRING' is obsolete.
configure.ac:80: You should run autoupdate.
./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from...
configure.ac:80: the top level
configure.ac:84: warning: The macro `AC_HELP_STRING' is obsolete.
configure.ac:84: You should run autoupdate.
./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from...
configure.ac:84: the top level
configure.ac:113: warning: The macro `AC_HELP_STRING' is obsolete.
configure.ac:113: You should run autoupdate.
./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from...
configure.ac:113: the top level
configure.ac:129: warning: $as_echo is obsolete; use AS_ECHO(["message"]) instead
lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
./lib/autoconf/general.m4:2249: AC_CACHE_VAL is expanded from...
./lib/autoconf/general.m4:2270: AC_CACHE_CHECK is expanded from...
m4/ax_pthread.m4:89: AX_PTHREAD is expanded from...
configure.ac:129: the top level
configure.ac:11: installing 'config/ar-lib'
configure.ac:11: installing 'config/compile'
configure.ac:20: installing 'config/config.guess'
configure.ac:20: installing 'config/config.sub'
configure.ac:9: installing 'config/install-sh'
configure.ac:9: installing 'config/missing'
Makefile.am: installing 'config/depcomp'
configure.ac: installing 'config/ylwrap'
parallel-tests: installing 'config/test-driver'

 $ ../configure --without-oniguruma --disable-maintainer-mode
checking for a BSD-compatible install... /opt/homebrew/bin/ginstall -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... /opt/homebrew/bin/gmkdir -p
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking whether make supports the include directive... yes (GNU style)
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for ar... ar
checking the archiver (ar) interface... ar
checking whether to enable maintainer-specific portions of Makefiles... no
checking for gcc... (cached) gcc
checking whether the compiler supports GNU C... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to enable C11 features... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking how to run the C preprocessor... gcc -E
checking for bison... bison -y
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for wchar.h... yes
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking whether _XOPEN_SOURCE should be defined... no
checking build system type... aarch64-apple-darwin22.5.0
checking host system type... aarch64-apple-darwin22.5.0
checking how to print strings... printf
checking for a sed that does not truncate output... /opt/homebrew/bin/gsed
checking for grep that handles long lines and -e... /opt/homebrew/bin/ggrep
checking for egrep... /opt/homebrew/bin/ggrep -E
checking for fgrep... /opt/homebrew/bin/ggrep -F
checking for ld used by gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
checking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 786432
checking how to convert aarch64-apple-darwin22.5.0 file names to aarch64-apple-darwin22.5.0 format... func_convert_file_noop
checking how to convert aarch64-apple-darwin22.5.0 file names to toolchain format... func_convert_file_noop
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld option to reload object files... -r
checking for file... file
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @FILE support... no
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for lipo... lipo
checking for otool... otool
checking for otool64... no
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking for -force_load linker flag... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... yes
checking for gcc option to produce PIC... -fno-common -DPIC
checking if gcc PIC flag -fno-common -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin22.5.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking for valgrind... no
configure: WARNING: valgrind is required to test jq.
checking for memmem... yes
checking for mkstemp... yes
checking for sys/cygwin.h... no
checking for shlwapi.h... no
checking for pipenv... pipenv
Aborted!
no
configure: WARNING: Error checking python dependencies:
*****************************************************************
*  Python dependencies for building jq documentation not found. *
*  You can still build, install and hack on jq, but the manpage *
*  will not be rebuilt and new manpage tests will not be run.   *
*  See docs/README.md for how to install the docs dependencies. *
*****************************************************************
checking whether gcc is Clang... yes
checking whether pthreads work with "-pthread" and "-lpthread"... yes
checking whether Clang needs flag to prevent "argument unused" warning when linking with -pthread... no
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking whether more special flags are required for pthreads... no
checking for PTHREAD_PRIO_INHERIT... yes
checking for size_t... yes
checking for working alloca.h... yes
checking for alloca... yes
checking for isatty... yes
checking for _isatty... no
checking for strptime... yes
checking for strftime... yes
checking for setenv... yes
checking for timegm... yes
checking for gmtime_r... yes
checking for gmtime... yes
checking for localtime_r... yes
checking for localtime... yes
checking for gettimeofday... yes
checking for struct tm.tm_gmtoff... yes
checking for struct tm.__tm_gmtoff... no
checking for pthread_key_create... yes
checking for pthread_once... yes
checking for atexit... yes
checking for acos in -lm... yes
checking for acosh in -lm... yes
checking for asin in -lm... yes
checking for asinh in -lm... yes
checking for atan2 in -lm... yes
checking for atan in -lm... yes
checking for atanh in -lm... yes
checking for cbrt in -lm... yes
checking for ceil in -lm... yes
checking for copysign in -lm... yes
checking for cos in -lm... yes
checking for cosh in -lm... yes
checking for drem in -lm... no
checking for erf in -lm... yes
checking for erfc in -lm... yes
checking for exp10 in -lm... no
checking for __exp10 in -lm... yes
checking for exp2 in -lm... yes
checking for exp in -lm... yes
checking for expm1 in -lm... yes
checking for fabs in -lm... yes
checking for fdim in -lm... yes
checking for floor in -lm... yes
checking for fma in -lm... yes
checking for fmax in -lm... yes
checking for fmin in -lm... yes
checking for fmod in -lm... yes
checking for frexp in -lm... yes
checking for gamma in -lm... no
checking for hypot in -lm... yes
checking for j0 in -lm... yes
checking for j1 in -lm... yes
checking for jn in -lm... yes
checking for ldexp in -lm... yes
checking for lgamma in -lm... yes
checking for log10 in -lm... yes
checking for log1p in -lm... yes
checking for log2 in -lm... yes
checking for log in -lm... yes
checking for logb in -lm... yes
checking for modf in -lm... yes
checking for lgamma_r in -lm... yes
checking for nearbyint in -lm... yes
checking for nextafter in -lm... yes
checking for nexttoward in -lm... yes
checking for pow10 in -lm... no
checking for pow in -lm... yes
checking for remainder in -lm... yes
checking for rint in -lm... yes
checking for round in -lm... yes
checking for scalb in -lm... yes
checking for scalbln in -lm... yes
checking for significand in -lm... no
checking for scalbn in -lm... yes
checking for ilogb in -lm... yes
checking for sin in -lm... yes
checking for sinh in -lm... yes
checking for sqrt in -lm... yes
checking for tan in -lm... yes
checking for tanh in -lm... yes
checking for tgamma in -lm... yes
checking for trunc in -lm... yes
checking for y0 in -lm... yes
checking for y1 in -lm... yes
checking for yn in -lm... yes
checking for thread-local storage... yes
checking whether byte ordering is bigendian... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating libjq.pc
config.status: executing depfiles commands
config.status: executing libtool commands

 $ make
mkdir -p src
  GEN      src/builtin.inc
mkdir -p src
  GEN      src/version.h
/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-recursive
  CC       src/main.o
  CC       src/builtin.lo
  CC       src/bytecode.lo
  CC       src/compile.lo
../src/compile.c:377:7: warning: variable 'nrefs' set but not used [-Wunused-but-set-variable]
  int nrefs = 0;
      ^
1 warning generated.
  CC       src/execute.lo
  CC       src/jq_test.lo
  CC       src/jv.lo
  CC       src/jv_alloc.lo
  CC       src/jv_aux.lo
  CC       src/jv_dtoa.lo
../src/jv_dtoa.c:2330:54: warning: unused variable 'test_scale' [-Wunused-variable]
        int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, e, e1, test_scale;
                                                            ^
1 warning generated.
  CC       src/jv_file.lo
  CC       src/jv_parse.lo
  CC       src/jv_print.lo
  CC       src/jv_unicode.lo
  CC       src/linker.lo
  CC       src/locfile.lo
  CC       src/util.lo
../src/util.c:3:9: warning: '_GNU_SOURCE' macro redefined [-Wmacro-redefined]
#define _GNU_SOURCE
        ^
<command line>:22:9: note: previous definition is here
#define _GNU_SOURCE 1
        ^
1 warning generated.
  CC       src/decNumber/decContext.lo
  CC       src/decNumber/decNumber.lo
  CC       src/jv_dtoa_tsd.lo
  CC       src/lexer.lo
src/lexer.c:1709:41: warning: comparison of integers of different signs: 'unsigned long' and 'int' [-Wsign-compare]
        if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
  CC       src/parser.lo
src/parser.c:2435:9: warning: variable 'yynerrs' set but not used [-Wunused-but-set-variable]
    int yynerrs = 0;
        ^
1 warning generated.
  CCLD     libjq.la
  CCLD     jq
  GEN      jq.1

 $ ./jq --version
jq-master-03db550

@itchyny
Copy link
Contributor

itchyny commented Jul 1, 2023

Ah, I can reproduce this in Ubuntu (on Docker).

@itchyny
Copy link
Contributor

itchyny commented Jul 1, 2023

This issue seems to be caused by the build skipping targets of .y.c and .l.c. Following patch fixes the issue, but looks ugly, and autoreconf warns non-POSIX variable name.

diff --git a/Makefile.am b/Makefile.am
index 247352f..ddf0497 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -42,8 +42,10 @@ else
 BUILT_SOURCES = src/builtin.inc src/version.h
 .y.c:
 	$(AM_V_YACC) echo "NOT building parser.c!"
+	@test "$(<D)" = "$(@D)" || cp -f "$(<:.y=.c)" "$@"
 .l.c:
 	$(AM_V_LEX) echo "NOT building lexer.c!"
+	@test "$(<D)" = "$(@D)" || cp -f "$(<:.l=.c)" "$@"
 endif

@itchyny
Copy link
Contributor

itchyny commented Jul 1, 2023

I should better solve why the srcdir (or VPATH) is not prepended on compiling these .c files.

@itchyny itchyny removed this from the 1.7 release milestone Jul 3, 2023
@goodpaperman
Copy link
Author

thanks a lot~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants