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

[Bug]: Gnucobol from Termux Packages cobc binary doesn't call clang properly #10863

Closed
vyuh opened this issue May 30, 2022 · 3 comments
Closed
Labels
bug report Something is not working properly

Comments

@vyuh
Copy link

vyuh commented May 30, 2022

Problem description

I was trying to compile a sample COBOL hello world program but got an error clang-14: error: no such file or directory: 'z'. Please see the following transcript showing commands and output.

$ cat helo.cob
      * Sample COBOL program
       IDENTIFICATION DIVISION.
       PROGRAM-ID. hello.
       PROCEDURE DIVISION.
       DISPLAY "Hello, world!".
       STOP RUN.
~ $ cobc -x helo.cob --verbose
cobc (GnuCOBOL) 3.1.2.0
Built     Jan 02 2022 12:24:38  Packaged  Dec 23 2020 12:04:58 UTC
C version "Android (7714059, based on r416183c1) Clang 12.0.8 (https://android.googlesource.com/toolchain/llvm-project c935d99d7cf2016289302412d708641d52d2f7ee)"
loading standard configuration file 'default.conf'
command line:   cobc -x --verbose helo.cob
preprocessing:  helo.cob -> /data/data/com.termux/files/usr/tmp/cob20281_0.cob
return status:  0
parsing:        /data/data/com.termux/files/usr/tmp/cob20281_0.cob (helo.cob)
return status:  0
translating:    /data/data/com.termux/files/usr/tmp/cob20281_0.cob -> /data/data/com.termux/files/usr/tmp/cob20281_0.c (helo.cob)
executing:      aarch64-linux-android-clang -c -fstack-protector-strong z
                -pipe -I/data/data/com.termux/files/usr/include
                -I/data/data/com.termux/files/usr/include
                -I/data/data/com.termux/files/usr/include -Wno-unused
                -fsigned-char -Wno-pointer-sign -Qunused-arguments -o
                "/data/data/com.termux/files/usr/tmp/cob20281_0.o"
                "/data/data/com.termux/files/usr/tmp/cob20281_0.c"
clang-14: error: no such file or directory: 'z'
return status:  1

I then built Gnucobol 3.1.2 release sources in Termux environment using ./configure --prefix=$HOME/PREFIX && make && make install. I could compile the same source file helo.cob with the cobc binary of this build. The resulting binary helo worked (though it needed some help with LD_LIBRARY_PATH). I'm including terminal transcript for comparison.

~ $ ~/PREFIX/bin/cobc -x helo.cob --verbose
cobc (GnuCOBOL) 3.1.2.0
Built     May 30 2022 11:05:35  Packaged  Dec 23 2020 12:04:58 UTC
C version "Clang 14.0.3"
loading standard configuration file 'default.conf'
command line:   /data/data/com.termux/files/home/PREFIX/bin/cobc -x --verbose helo.cob
preprocessing:  helo.cob -> /data/data/com.termux/files/usr/tmp/cob20431_0.cob
return status:  0
parsing:        /data/data/com.termux/files/usr/tmp/cob20431_0.cob (helo.cob)
return status:  0
translating:    /data/data/com.termux/files/usr/tmp/cob20431_0.cob -> /data/data/com.termux/files/usr/tmp/cob20431_0.c (helo.cob)
executing:      gcc -c -pipe -I/data/data/com.termux/files/usr/include
                -I/data/data/com.termux/files/home/PREFIX/include -Wno-unused
                -fsigned-char -Wno-pointer-sign -Qunused-arguments -o
                "/data/data/com.termux/files/usr/tmp/cob20431_0.o"
                "/data/data/com.termux/files/usr/tmp/cob20431_0.c"
return status:  0
executing:      gcc -Wl,--export-dynamic -o "helo"
                "/data/data/com.termux/files/usr/tmp/cob20431_0.o"
                -L/data/data/com.termux/files/home/PREFIX/lib -lcob -lm
return status:  0
~ $ ./helo
WARNING: linker: /data/data/com.termux/files/home/helo: unsupported flags DT_FLAGS_1=0x8000001
CANNOT LINK EXECUTABLE "./helo": library "libcob.so.4" not found
Aborted
~ $ LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$HOME/PREFIX/lib" ./helo
WARNING: linker: Warning: unable to normalize ""
WARNING: linker: /data/data/com.termux/files/home/helo: unsupported flags DT_FLAGS_1=0x8000001
Hello, world!
~ $ termux-elf-cleaner helo
termux-elf-cleaner: Replacing unsupported DF_1_* flags 134217729 with 1 in 'helo'
~ $ LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$HOME/PREFIX/lib" ./helo
WARNING: linker: Warning: unable to normalize ""
Hello, world!
~ $

Notice that the Termux packages version of cobc adds -fstack-protector-strong z to the arguments of clang. This doesn't happen with cobc binary built by me from source.

I'm hoping this can be fixed by changing something in the Termux build scripts.

What steps will reproduce the bug?

compile helo.cob with command cobc -x helo.cob. command fails with error message: clang-14: error: no such file or directory: 'z'.

Contents of helo.cob:

      * Sample COBOL program
       IDENTIFICATION DIVISION.
       PROGRAM-ID. hello.
       PROCEDURE DIVISION.
       DISPLAY "Hello, world!".
       STOP RUN.

What is the expected behavior?

Should produce executable helo from helo.cob

System information

termux-info:

Termux Variables:
TERMUX_API_VERSION=0.50.1
TERMUX_APK_RELEASE=F_DROID
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=25427
TERMUX_IS_DEBUGGABLE_BUILD=0
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://grimler.se/termux-packages-24/ stable main
Updatable packages:
clang/stable 14.0.4 aarch64 [upgradable from: 14.0.3-1]
libcompiler-rt/stable 14.0.4 aarch64 [upgradable from: 14.0.3-1]
libllvm/stable 14.0.4 aarch64 [upgradable from: 14.0.3-1]
lld/stable 14.0.4 aarch64 [upgradable from: 14.0.3-1]
llvm/stable 14.0.4 aarch64 [upgradable from: 14.0.3-1]
termux-tools version:
0.184
Android version:
7.1.2
Kernel build information:
Linux localhost 3.18.31-perf-g6507e5c #1 SMP PREEMPT Thu Nov 7 22:33:14 WIB 2019 aarch64 Android
Device manufacturer:
Xiaomi
Device model:
Redmi 4

@vyuh vyuh added the bug report Something is not working properly label May 30, 2022
@Grimler91
Copy link
Member

Please try gnucobol 3.2.1-1 when it is available shortly. Termux passes -Oz as optimisation level, but it was not recognised by gnucobol's configure script, which tries to remove optimisation levels through various sed patterns

@Grimler91
Copy link
Member

Grimler91 commented May 30, 2022

Also note that your locally compiled gnucobol doesn't set RPATH, requiring you to use LD_LIBRARY_PATH. With termux's gnucobol that shouldn't be needed (not to make the program find libcob.so at least)

@vyuh
Copy link
Author

vyuh commented May 31, 2022

I checked and found that this works as expected. Thank You for your work on Termux @Grimler91.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Something is not working properly
Projects
None yet
Development

No branches or pull requests

2 participants