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

build-sys: fix cross-compilation failure caused by building/executing packcc #2747

Merged
merged 3 commits into from
Dec 9, 2020

Conversation

leleliu008
Copy link
Member

@masatake
Copy link
Member

masatake commented Dec 1, 2020

Just "issues 2731 solution" is not a good commit log header.
How about "build-sys: fix cross-compilation failure caused by building/executing packcc" ?

I need a well-descriptive commit log to understand your change.
How can we use your change? I would like to see an example command line.
I would like you to write these things to the commit log or docs/autotools.rst.

You turned off checking the existence of strnlen. This causes building failures on Windows.
Can we do checking the existence of strnlen with *_FOR_BUILD macros.

@coveralls
Copy link

coveralls commented Dec 1, 2020

Coverage Status

Coverage increased (+0.05%) to 87.126% when pulling 9d7450a on leleliu008:master into bdb7d99 on universal-ctags:master.

@leleliu008
Copy link
Member Author

1、use AX_PROG_CXX_FOR_BUILD macro, this macro is provided by autoconf-archive project which is widely used for supporting cross-compilation. the offical document is here
2、user can setting CC_FOR_BUILDCFLAGS_FOR_BUILDCPPFLAGS_FOR_BUILDLDFLAGS_FOR_BUILD when cross-compiling. when normal-compiling, FOO_FOR_BUILD is same as FOO.
3、cross-compilation example:

configure \
    --host=armv7a-linux-androideabi \
    --prefix=`pwd`/out \
    --enable-static \
    --disable-seccomp \
    CC=/usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi21-clang \
    CFLAGS='--sysroot /usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -Qunused-arguments -Os -fpic' \
    CPP='/usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi21-clang -E' \
    CPPFLAGS='-I/Users/leleliu008/.ndk-pkg/pkg/jansson/armeabi-v7a/include -I/Users/leleliu008/.ndk-pkg/pkg/libyaml/armeabi-v7a/include -I/Users/leleliu008/.ndk-pkg/pkg/libxml2/armeabi-v7a/include -I/Users/leleliu008/.ndk-pkg/pkg/libiconv/armeabi-v7a/include --sysroot /usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -Qunused-arguments -Dftello=ftell -Dfseeko=fseek' \
    LDFLAGS='-L/Users/leleliu008/.ndk-pkg/pkg/jansson/armeabi-v7a/lib -L/Users/leleliu008/.ndk-pkg/pkg/libyaml/armeabi-v7a/lib -L/Users/leleliu008/.ndk-pkg/pkg/libxml2/armeabi-v7a/lib -L/Users/leleliu008/.ndk-pkg/pkg/libiconv/armeabi-v7a/lib --sysroot /usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/sysroot' \
    AR=/usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ar \
    RANLIB=/usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ranlib \
    CC_FOR_BUILD=/usr/bin/cc \
    CFLAGS_FOR_BUILD='-v' \
    PKG_CONFIG_PATH=/Users/leleliu008/.ndk-pkg/pkg/libiconv/armeabi-v7a/lib/pkgconfig:/Users/leleliu008/.ndk-pkg/pkg/libxml2/armeabi-v7a/lib/pkgconfig:/Users/leleliu008/.ndk-pkg/pkg/libyaml/armeabi-v7a/lib/pkgconfig:/Users/leleliu008/.ndk-pkg/pkg/jansson/armeabi-v7a/lib/pkgconfig \
    PKG_CONFIG_LIBDIR=/Users/leleliu008/.ndk-pkg/pkg

@@ -28,6 +28,7 @@ uname -mrsv 2>/dev/null
AM_INIT_AUTOMAKE([foreign subdir-objects tar-ustar])
AM_SILENT_RULES([yes])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
Copy link
Member Author

@leleliu008 leleliu008 Dec 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +258 to +261
AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])
AC_ARG_VAR(CFLAGS_FOR_BUILD,[CFLAGS for build system C compiler])
AC_ARG_VAR(CPPFLAGS_FOR_BUILD,[CPPFLAGS for build system C compiler])
AC_ARG_VAR(LDFLAGS_FOR_BUILD,[LDFLAGS for build system C compiler])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let user config those variables when cross-compilation.

Comment on lines +244 to +245
# https://www.gnu.org/software/autoconf-archive/ax_prog_cc_for_build.html
AX_PROG_CC_FOR_BUILD
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inset a ready-to-use macro to support cross-compilation.

@@ -1,3 +1,5 @@
ACLOCAL_AMFLAGS = -I m4
Copy link
Member Author

@leleliu008 leleliu008 Dec 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aclocal -I m4

Note that if you use aclocal from Automake to generate aclocal.m4, you must also set ACLOCAL_AMFLAGS = -I dir in your top-level Makefile.am. Due to a limitation in the Autoconf implementation of autoreconf, these include directives currently must be set on a single line in Makefile.am, without any backslash-newlines.

doc

@k-takata
Copy link
Member

k-takata commented Dec 2, 2020

I think that BUILD_EXEEXT should be used:

--- a/Makefile.am
+++ b/Makefile.am
@@ -147,14 +147,14 @@ endif
 packcc_verbose = $(packcc_verbose_@AM_V@)
 packcc_verbose_ = $(packcc_verbose_@AM_DEFAULT_V@)
 packcc_verbose_0 = @echo PACKCC "    $@";
-PACKCC = $(top_builddir)/packcc$(EXEEXT)
+PACKCC = $(top_builddir)/packcc$(BUILD_EXEEXT)
 SUFFIXES += .peg
 .peg.c:
 	$(packcc_verbose)$(PACKCC) -i \"general.h\" -o $(top_builddir)/peg/$(*F) "$<"
 .peg.h:
 	$(packcc_verbose)$(PACKCC) -i \"general.h\" -o $(top_builddir)/peg/$(*F) "$<"
 # You cannot use $(PACKCC) as a target name here.
-$(PEG_SRCS) $(PEG_HEADS): packcc$(EXEEXT) Makefile
+$(PEG_SRCS) $(PEG_HEADS): packcc$(BUILD_EXEEXT) Makefile
 dist_libctags_a_SOURCES = $(ALL_LIB_HEADS) $(ALL_LIB_SRCS)
 
 ctags_CPPFLAGS = $(libctags_a_CPPFLAGS)

@k-takata k-takata changed the title issues 2731 solution build-sys: fix cross-compilation failure caused by building/executing packcc Dec 2, 2020
@codecov
Copy link

codecov bot commented Dec 2, 2020

Codecov Report

Merging #2747 (9d7450a) into master (e52cf4a) will increase coverage by 0.04%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2747      +/-   ##
==========================================
+ Coverage   86.99%   87.04%   +0.04%     
==========================================
  Files         190      191       +1     
  Lines       40450    40757     +307     
==========================================
+ Hits        35190    35477     +287     
- Misses       5260     5280      +20     
Impacted Files Coverage Δ
parsers/verilog.c 96.97% <0.00%> (-0.68%) ⬇️
parsers/haskell.c 91.12% <0.00%> (ø)
main/entry.c 88.61% <0.00%> (+0.24%) ⬆️
parsers/vhdl.c 96.26% <0.00%> (+0.86%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e52cf4a...9d7450a. Read the comment docs.

Comment on lines +49 to +51
PACKCC = $(top_builddir)/packcc$(BUILD_EXEEXT)

$(PACKCC):
$(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) $(EXTRA_CPPFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ $(top_srcdir)/misc/packcc/packcc.c
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build packcc don't follow The Uniform Naming Scheme. because automake auto append $(EXEEXT) to *_PROGRAMS when generating the Makefile, but here we want to use $(BUILD_EXEEXT).

@masatake
Copy link
Member

masatake commented Dec 2, 2020

@leleliu008, thank you for putting comments in your change.
However, what we need is better commit log messages, not comment.
Could you read again my last comment?

I need a well-descriptive commit log to understand your change.

@leleliu008
Copy link
Member Author

@masatake OK, I will rewrite my commit messages.

@masatake
Copy link
Member

masatake commented Dec 3, 2020

I tried this change and I confirmed the change works expectedly.
The steps I tried can be run on any where OCI container runs.


Pull a container image for fedora33
# podman pull docker.io/library/fedora:33

Run the container for the image
# podman run docker.io/library/fedora:33 -ta bash

Prepare a repo file for a toolchain (in the container)
(I must read https://bugzilla.redhat.com/show_bug.cgi?id=1378882)

# cd /etc/yum.repos.d;
# curl -O https://copr.fedorainfracloud.org/coprs/lantw44/aarch64-linux-gnu-toolchain/repo/fedora-33/lantw44-aarch64-linux-gnu-toolchain-fedora-33.repo

Install packages_nameb
# dnf -y install aarch64-linux-gnu-{binutils,gcc,glibc} git gcc autoconf automake make

Get ctags source code
# git clone https://github.com/universal-ctags/ctags
# git checkout -b leleliu008-master master
# git pull https://github.com/leleliu008/ctags.git master

Build
# bash ./autogen.sh
# mkdir out
# ./configure
--host=aarch64-linux-gnu
--prefix=pwd/out
--enable-static
--disable-seccomp
CC=/usr/bin/aarch64-linux-gnu-gcc
CPP=/usr/bin/aarch64-linux-gnu-cpp
AR=/usr/bin/aarch64-linux-gnu-gcc-ar
RANLIB=/usr/bin/aarch64-linux-gnu-gcc-ranlib
CC_FOR_BUILD=/usr/bin/gcc
# make

Verify
# make install
# file ./out/bin/ctags
ctags: ELF 64-bit LSB executable, ARM aarch64, version 1 (GNU/Linux),
statically linked, BuildID[sha1]=b52e44aea148bec570938c88a86e100c334c07e4,
for GNU/Linux 3.7.0, with debug_info, not stripped
# strings ctags | grep varlink
varlink
varlink.c
varlink_post.h
varlink.h
varlink_pre.h
peg/varlink.c
pvarlink_parse
pvarlink_context_t
pvarlink_destroy
pvarlink_create
pvarlink_context_tag
varlink.c
pvarlink_parse.part.0
pvarlink_parse
pvarlink_destroy
pvarlink_create

varlink implies packcc works well during building.

Makefile.am Outdated Show resolved Hide resolved
@masatake
Copy link
Member

masatake commented Dec 4, 2020

valgrind reports many errors. I wonder why. I guess the errors are nothing to do with the changes for cross-compilation.
I will inspect the errors.

@masatake
Copy link
Member

masatake commented Dec 4, 2020

It couldn't be reproduced locally.

@k-takata
Copy link
Member

k-takata commented Dec 4, 2020

The commit is somewhat strange. It includes an unnecessary merge commit and some duplicated commits.

image

This should be fixed by:

git reset --hard c54a2cf
git cherry-pick fe1b11d
git push --force

And the commit messages don't include the build-sys: prefix.
@masatake Is it okay?

@masatake
Copy link
Member

masatake commented Dec 4, 2020

@k-takata, thank you.

@leleliu008.
multiple commits are in this pull request.
They are not semantically separated but they represent the process of development. @leleliu008, do you agree with me?
If yes, I would like you to squash your changes into one commit including commit logs, and rename the title of the new commit
to "build-sys: fix cross-compilation failure caused by building/executing packcc". I don't think "issues 2731 solution" is a good title.

In addition, I would like to do cherry-pick d6a674a ae30b92 in #2748 ?
If you don't find a way to do so, I myself will push d6a674a ae30b92 here. I put it at the end of this comment.

There are two extra TODO items I would like to solve before merging this pull request:
(1) fix the errors reported by Valgrind. This may be nothing to do with the changes in this pull request. However, we must fix them before merging. I take this task.
(2) write about cross-compilation in docs/autotools.rst. I take this task. I would like you to review my change.

commit ae30b92c8db73bc9f7a3233c52ac547a95cec774
Author: Masatake YAMATO <[email protected]>
Date:   Fri Dec 4 14:58:10 2020 +0900

    circleci: testing the cross-compilation for aarch64-linux-gnu
    
    Signed-off-by: Masatake YAMATO <[email protected]>

diff --git a/circle.yml b/circle.yml
index 606c5f91..e93b71fb 100644
--- a/circle.yml
+++ b/circle.yml
@@ -160,6 +160,48 @@ jobs:
              # make check roundtrip CIRCLECI=1
              make units CIRCLECI=1 CATEGORIES=parser-varlink
 
+   fedora33_cross_aarch64:
+     working_directory: ~/universal-ctags
+     docker:
+       - image: docker.io/library/fedora:33
+     steps:
+       - run:
+           name: Install tools
+           command: |
+             dnf -y install git gcc autoconf automake make
+       - run:
+           name: Prepare repo file for install cross compiler
+           command: |
+             curl -o /etc/yum.repos.d/lantw44-aarch64-linux-gnu-toolchain-fedora-33.repo https://copr.fedorainfracloud.org/coprs/lantw44/aarch64-linux-gnu-toolchain/repo/fedora-33/lantw44-aarch64-linux-gnu-toolchain-fedora-33.repo
+       - run:
+           name: Install the cross compiler for aarch64
+           command: |
+             dnf -y install aarch64-linux-gnu-binutils aarch64-linux-gnu-gcc aarch64-linux-gnu-glibc
+       - checkout
+       - run:
+           name: Build ctags for aarch64
+           command: |
+             bash ./autogen.sh
+             mkdir out
+             ./configure --host=aarch64-linux-gnu \
+             --prefix=`pwd`/out \
+             --enable-static \
+             --disable-seccomp \
+             CC=/usr/bin/aarch64-linux-gnu-gcc \
+             CPP=/usr/bin/aarch64-linux-gnu-cpp \
+             AR=/usr/bin/aarch64-linux-gnu-gcc-ar \
+             RANLIB=/usr/bin/aarch64-linux-gnu-gcc-ranlib \
+             CC_FOR_BUILD=/usr/bin/gcc
+             make -j 2
+       - run:
+           name: Install locally
+           command: |
+             make install
+       - run:
+           name: Test
+           command: |
+             test -f out/bin/ctags
+
 workflows:
   version: 2
   build_and_test:
@@ -169,3 +211,4 @@ workflows:
       - fedora_distcheck
       - centos_make
       - fedora32_gmake
+      - fedora33_cross_aarch64

… packcc

there exists a ready-to-use macro called `AX_PROG_CXX_FOR_BUILD` which is provided by `ax_prog_cc_for_build.m4` and is widely used for supporting cross-compilation. this macro defined `CC_FOR_BUILD`, `CFLAGS_FOR_BUILD`, `CPPFLAGS_FOR_BUILD`, `LDFLAGS_FOR_BUILD`, `BUILD_EXEEXT` variables. user can set `CC_FOR_BUILD`、`CFLAGS_FOR_BUILD`、`CPPFLAGS_FOR_BUILD`、`LDFLAGS_FOR_BUILD` when cross-compiling. when native-compiling, `FOO_FOR_BUILD` is same as `FOO`. here is a example show you how to use these variables:

configure \
    --host=armv7a-linux-androideabi \
    --prefix=`pwd`/out \
    --enable-static \
    --disable-seccomp \
    CC=/usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi21-clang \
    CFLAGS='-v' \
    CPP='/usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi21-clang -E' \
    CPPFLAGS='-I/Users/leleliu008/.ndk-pkg/pkg/jansson/armeabi-v7a/include -I/Users/leleliu008/.ndk-pkg/pkg/libyaml/armeabi-v7a/include -I/Users/leleliu008/.ndk-pkg/pkg/libxml2/armeabi-v7a/include -I/Users/leleliu008/.ndk-pkg/pkg/libiconv/armeabi-v7a/include --sysroot /usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -Qunused-arguments -Dftello=ftell -Dfseeko=fseek' \
    LDFLAGS='-L/Users/leleliu008/.ndk-pkg/pkg/jansson/armeabi-v7a/lib -L/Users/leleliu008/.ndk-pkg/pkg/libyaml/armeabi-v7a/lib -L/Users/leleliu008/.ndk-pkg/pkg/libxml2/armeabi-v7a/lib -L/Users/leleliu008/.ndk-pkg/pkg/libiconv/armeabi-v7a/lib --sysroot /usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/sysroot' \
    AR=/usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ar \
    RANLIB=/usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ranlib \
    CC_FOR_BUILD=/usr/bin/cc \
    CFLAGS_FOR_BUILD='-v' \
    PKG_CONFIG_PATH=/Users/leleliu008/.ndk-pkg/pkg/libiconv/armeabi-v7a/lib/pkgconfig:/Users/leleliu008/.ndk-pkg/pkg/libxml2/armeabi-v7a/lib/pkgconfig:/Users/leleliu008/.ndk-pkg/pkg/libyaml/armeabi-v7a/lib/pkgconfig:/Users/leleliu008/.ndk-pkg/pkg/jansson/armeabi-v7a/lib/pkgconfig \
    PKG_CONFIG_LIBDIR=/Users/leleliu008/.ndk-pkg/pkg

ax_prog_cc_for_build.m4 has been downloaded from `http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;f=m4/ax_prog_cc_for_build.m4` and placed in m4 directory. to use aclocal from Automake to generate aclocal.m4, we must also set `ACLOCAL_AMFLAGS = -I m4` in top-level Makefile.am.

build packcc don't follow `The Uniform Naming Scheme`. because automake auto append `$(EXEEXT)` to `*_PROGRAMS` when generating the Makefile, but here we want to use `$(BUILD_EXEEXT)`. as we don't use `The Uniform Naming Scheme`, we must clean `packcc` and `packcc.exe` by myself.

References:
*https://www.gnu.org/software/autoconf-archive/ax_prog_cc_for_build.html
*https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Input.html
*https://www.gnu.org/software/automake/manual/html_node/Uniform.html
@leleliu008
Copy link
Member Author

@masatake I have been squashed all of my commits into one. Do you wish me to run git cherry-pick d6a674a ae30b92? or you will do?

@masatake
Copy link
Member

masatake commented Dec 5, 2020

Do you wish me to run git cherry-pick d6a674a ae30b92? or you will do?

Please, do it.

@masatake
Copy link
Member

masatake commented Dec 5, 2020

I found the bug report is about -O2 option. Temporarily, I use '-O0' for running tests under valgrind.
So the last item is about documents.

@leleliu008
Copy link
Member Author

@masatake

Compile your program with -g to include debugging information so that Memcheck's error messages include exact line numbers. 
Using -O0 is also a good idea, if you can tolerate the slowdown. 
With -O1 line numbers in error messages can be inaccurate, although generally speaking running Memcheck on code compiled at -O1 works fairly well, and the speed improvement compared to running -O0 is quite significant. 
Use of -O2 and above is not recommended as Memcheck occasionally reports uninitialised-value errors which don't really exist.

--from offical valgrind document

@masatake
Copy link
Member

masatake commented Dec 5, 2020

@leleliu008, thank you! Using -O1 looks good for us.

@masatake
Copy link
Member

masatake commented Dec 5, 2020

I wrote a draft version of the document based on your commit log.
I would like you to add this to your pull request after revising it. I'm not good at Englsh. So your revising is a must.
I would like to use "docs(web): write about cross-compilation" as the header for the commit log.

diff --git a/docs/autotools.rst b/docs/autotools.rst
index 802a008c..40aa9ad2 100644
--- a/docs/autotools.rst
+++ b/docs/autotools.rst
@@ -68,3 +68,56 @@ To completely change the program's name run the following:
        $ ./configure --program-transform-name='s/ctags/my_ctags/; s/etags/myemacs_tags/'
 
 Please remember there is also an 'etags' installed alongside 'ctags' which you may also want to rename as shown above.
+
+Cross-compilation
+,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+
+The way for cross-compilation is a bit complicated because the
+build-system of ctags uses `packcc`, a code generator written in C
+language. It means you prepare two C compilers running on the host
+environment; one emits code for the target architecture for compiling
+`ctags`, and another emits code for the host architecture for
+compiling `packcc`.
+
+There exists a ready-to-use macro called `AX_PROG_CXX_FOR_BUILD` which
+is provided by `ax_prog_cc_for_build.m4` and is widely used for
+supporting cross-compilation. This macro defined `CC_FOR_BUILD`,
+`CFLAGS_FOR_BUILD`, `CPPFLAGS_FOR_BUILD`, `LDFLAGS_FOR_BUILD`,
+`BUILD_EXEEXT` variables. User can set `CC_FOR_BUILD`,
+`CFLAGS_FOR_BUILD`, `CPPFLAGS_FOR_BUILD`, `LDFLAGS_FOR_BUILD` when
+cross-compiling. When native-compiling, `FOO_FOR_BUILD` is same as
+`FOO`.
+
+`FOO` variables for tools emitting code for the target architecture.
+`FOO_FOR_BUILD` variables for tools emitting code for the host architecture.
+
+Here is an example to show you how to use these variables:
+
+::
+
+       $ mkdir ./out
+       $ configure \
+               --host=armv7a-linux-androideabi \
+               --prefix=`pwd`/out \
+               --enable-static \
+               --disable-seccomp \
+               CC=/usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi21-clang \
+               CFLAGS='-v' \
+               CPP='/usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi21-clang -E' \
+               CPPFLAGS='-I/Users/leleliu008/.ndk-pkg/pkg/jansson/armeabi-v7a/include -I/Users/leleliu008/.ndk-pkg/pkg/libyaml/armeabi-v7a/include -I/Users/leleliu008/.ndk-pkg/pkg/libxml2/armeabi-v7a/include -I/Users/leleliu008/.ndk-pkg/pkg/libiconv/armeabi-v7a/include --sysroot /usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -Qunused-arguments -Dftello=ftell -Dfseeko=fseek' \
+               LDFLAGS='-L/Users/leleliu008/.ndk-pkg/pkg/jansson/armeabi-v7a/lib -L/Users/leleliu008/.ndk-pkg/pkg/libyaml/armeabi-v7a/lib -L/Users/leleliu008/.ndk-pkg/pkg/libxml2/armeabi-v7a/lib -L/Users/leleliu008/.ndk-pkg/pkg/libiconv/armeabi-v7a/lib --sysroot /usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/sysroot' \
+               AR=/usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ar \
+               RANLIB=/usr/local/opt/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ranlib \
+               CC_FOR_BUILD=/usr/bin/cc \
+               CFLAGS_FOR_BUILD='-v' \
+               PKG_CONFIG_PATH=/Users/leleliu008/.ndk-pkg/pkg/libiconv/armeabi-v7a/lib/pkgconfig:/Users/leleliu008/.ndk-pkg/pkg/libxml2/armeabi-v7a/lib/pkgconfig:/Users/leleliu008/.ndk-pkg/pkg/libyaml/armeabi-v7a/lib/pkgconfig:/Users/leleliu008/.ndk-pkg/pkg/jansson/armeabi-v7a/lib/pkgconfig \
+               PKG_CONFIG_LIBDIR=/Users/leleliu008/.ndk-pkg/pkg
+       ...
+       $ make
+       ...
+       $ make install
+       ...
+       $ ls out/bin
+       ctags readtags
+
+Simpler example for `aarch64-linux-gnu` can be found in `circle.yml` in the source tree.

@masatake masatake mentioned this pull request Dec 5, 2020
@masatake
Copy link
Member

masatake commented Dec 5, 2020

@leleliu008, I have questions.
Are you working on this topic as a member of https://github.com/termux/termux-packages ?
Or are you contributing to https://github.com/termux/termux-packages ?

I got these questions because your pull request is very related to #2719.

@leleliu008
Copy link
Member Author

@masatake I'm not working on termux. Recently, I'm developing a package manager for Android NDK and Xcode. I'm porting universal-ctags to my package manager.

@masatake
Copy link
Member

masatake commented Dec 5, 2020

@masatake I'm not working on termux. Recently, I'm developing a package manager for Android NDK and Xcode. I'm porting universal-ctags to my package manager.

I see. Thank you.

@masatake masatake merged commit 6fd18b8 into universal-ctags:master Dec 9, 2020
@masatake
Copy link
Member

masatake commented Dec 9, 2020

@leleliu008, thank you.

@masatake masatake mentioned this pull request Dec 9, 2020
masatake added a commit to masatake/ctags that referenced this pull request Dec 19, 2020
https://www.valgrind.org/docs/manual/quick-start.html

    Compile your program with -g to include debugging information so that
    Memcheck's error messages include exact line numbers.  Using -O0 is
    also a good idea, if you can tolerate the slowdown.  With -O1 line
    numbers in error messages can be inaccurate, although generally
    speaking running Memcheck on code compiled at -O1 works fairly well,
    and the speed improvement compared to running -O0 is quite
    significant.  Use of -O2 and above is not recommended as Memcheck
    occasionally reports uninitialised-value errors which don't really
    exist.

Suggested by @leleliu008 at universal-ctags#2747
masatake added a commit to masatake/ctags that referenced this pull request Dec 19, 2020
https://www.valgrind.org/docs/manual/quick-start.html

    Compile your program with -g to include debugging information so that
    Memcheck's error messages include exact line numbers.  Using -O0 is
    also a good idea, if you can tolerate the slowdown.  With -O1 line
    numbers in error messages can be inaccurate, although generally
    speaking running Memcheck on code compiled at -O1 works fairly well,
    and the speed improvement compared to running -O0 is quite
    significant.  Use of -O2 and above is not recommended as Memcheck
    occasionally reports uninitialised-value errors which don't really
    exist.

Suggested by @leleliu008 at universal-ctags#2747
masatake added a commit to masatake/ctags that referenced this pull request Jan 1, 2021
https://www.valgrind.org/docs/manual/quick-start.html

    Compile your program with -g to include debugging information so that
    Memcheck's error messages include exact line numbers.  Using -O0 is
    also a good idea, if you can tolerate the slowdown.  With -O1 line
    numbers in error messages can be inaccurate, although generally
    speaking running Memcheck on code compiled at -O1 works fairly well,
    and the speed improvement compared to running -O0 is quite
    significant.  Use of -O2 and above is not recommended as Memcheck
    occasionally reports uninitialised-value errors which don't really
    exist.

Suggested by @leleliu008 at universal-ctags#2747
bobrik added a commit to bobrik/nixpkgs that referenced this pull request Feb 16, 2021
Newer versions fail on aarch64-linux:

```
  checking for aarch64-unknown-linux-gnu-gcc... aarch64-unknown-linux-gnu-gcc
  checking whether the compiler supports GNU C... yes
  checking whether aarch64-unknown-linux-gnu-gcc accepts -g... yes
  checking for aarch64-unknown-linux-gnu-gcc option to enable C11 features... (cached) none needed
  checking whether aarch64-unknown-linux-gnu-gcc understands -c and -o together... yes
  checking dependency style of aarch64-unknown-linux-gnu-gcc... none
  checking whether the C compiler works... no
  configure: error: in `/build/source':
  configure: error: C compiler cannot create executables
  See `config.log' for more details
```

The following PR is likely culprit:

* universal-ctags/ctags#2747
@k-takata k-takata mentioned this pull request Mar 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants