project-trident / trident-core

Core Packages and system overlay files
http://project-trident.org
BSD 2-Clause "Simplified" License
33 stars 10 forks source link

Unable to compile c program on trident stable #93

Closed fekir closed 5 years ago

fekir commented 5 years ago

Describe the bug I'm unable to compile a simple c test program in trident, neither with clang, nor with gcc.

To Reproduce Install trident. Optionally install gcc or other clang versions Compile a simple program See error on stderr

Expected behavior No error in stderr, and a working executable as output from the compiler.

OS Version:

FreeBSD trident-7822 12.0-STABLE FreeBSD 12.0-STABLE GENERIC  amd64

Additional context Hello,

I've played a little bit with trident, I'm sorry if I'm reporting this bug (or at least inconsistent behavior for which I found no documentation)

I've installed trident from the dvd, and after it different packages for developing in c++ and c, like clang, gcc, cppcheck and so on.

Unfortunately I'm not able to compile even a simple test program.

> clang80 -v main.c
clang version 8.0.1 (tags/RELEASE_801/final)
Target: x86_64-portbld-freebsd12.0
Thread model: posix
InstalledDir: /usr/local/llvm80/bin
 "/usr/local/llvm80/bin/clang-8" -cc1 -triple x86_64-portbld-freebsd12.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name main.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -v -resource-dir /usr/local/llvm80/lib/clang/8.0.1 -fdebug-compilation-dir /usr/home/trident/Workspace -ferror-limit 19 -fmessage-length 213 -fobjc-runtime=gnustep -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/main-5a085f.o -x c main.c -faddrsig
clang -cc1 version 8.0.1 based upon LLVM 8.0.1 default target x86_64-portbld-freebsd12.0
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/llvm80/lib/clang/8.0.1/include
 /usr/include
End of search list.
 "/usr/local/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --hash-style=both --enable-new-dtags -o a.out /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib /tmp/main-5a085f.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o
/usr/local/bin/ld: cannot find -lgcc
/usr/local/bin/ld: cannot find /usr/lib/libc_nonshared.a
/usr/local/bin/ld: cannot find /usr/lib/libssp_nonshared.a
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)

stderror of (verbose) gcc (gcc -v main.c)

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc8/gcc/x86_64-portbld-freebsd12.0/8.3.0/lto-wrapper
Target: x86_64-portbld-freebsd12.0
Configured with: /wrkdirs/usr/ports/lang/gcc8/work/gcc-8.3.0/configure --enable-multilib --with-build-config=bootstrap-debug --disable-nls --enable-gnu-indirect-function --libdir=/usr/local/lib/gcc8 --libexecdir=/usr/local/libexec/gcc8 --program-suffix=8 --with-as=/usr/local/bin/as --with-gmp=/usr/local --with-gxx-include-dir=/usr/local/lib/gcc8/include/c++/ --with-ld=/usr/local/bin/ld --with-pkgversion='FreeBSD Ports Collection' --with-system-zlib --enable-languages=c,c++,objc,fortran --prefix=/usr/local --localstatedir=/var --mandir=/usr/local/man --infodir=/usr/local/share/info/gcc8 --build=x86_64-portbld-freebsd12.0
Thread model: posix
gcc version 8.3.0 (FreeBSD Ports Collection) 
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=x86-64'
 /usr/local/libexec/gcc8/gcc/x86_64-portbld-freebsd12.0/8.3.0/cc1 -quiet -v main.c -quiet -dumpbase main.c -mtune=generic -march=x86-64 -auxbase main -version -o /tmp//ccD7LMZJ.s
GNU C17 (FreeBSD Ports Collection) version 8.3.0 (x86_64-portbld-freebsd12.0)
        compiled by GNU C version 8.3.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version none
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/lib/gcc8/gcc/x86_64-portbld-freebsd12.0/8.3.0/include-fixed"
ignoring nonexistent directory "/usr/local/lib/gcc8/gcc/x86_64-portbld-freebsd12.0/8.3.0/../../../../../x86_64-portbld-freebsd12.0/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc8/gcc/x86_64-portbld-freebsd12.0/8.3.0/include
 /usr/local/include
 /usr/include
End of search list.
GNU C17 (FreeBSD Ports Collection) version 8.3.0 (x86_64-portbld-freebsd12.0)
        compiled by GNU C version 8.3.0, GMP version 6.1.2, MPFR version 4.0.2, MPC version 1.1.0, isl version none
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: dd06a9b5f68761221f73f31b1557edca
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=x86-64'
 /usr/local/bin/as -v -o /tmp//ccwd2t4G.o /tmp//ccD7LMZJ.s
GNU assembler version 2.32 (x86_64-portbld-freebsd12.0) using BFD version (GNU Binutils) 2.32
COMPILER_PATH=/usr/local/libexec/gcc8/gcc/x86_64-portbld-freebsd12.0/8.3.0/:/usr/local/libexec/gcc8/gcc/x86_64-portbld-freebsd12.0/8.3.0/:/usr/local/libexec/gcc8/gcc/x86_64-portbld-freebsd12.0/:/usr/local/lib/gcc8/gcc/x86_64-portbld-freebsd12.0/8.3.0/:/usr/local/lib/gcc8/gcc/x86_64-portbld-freebsd12.0/:/usr/local/lib/gcc8/gcc/x86_64-portbld-freebsd12.0/8.3.0/../../../../../x86_64-portbld-freebsd12.0/bin/
LIBRARY_PATH=/usr/local/lib/gcc8/gcc/x86_64-portbld-freebsd12.0/8.3.0/:/usr/local/lib/gcc8/gcc/x86_64-portbld-freebsd12.0/8.3.0/../../../../../x86_64-portbld-freebsd12.0/lib/:/usr/local/lib/gcc8/gcc/x86_64-portbld-freebsd12.0/8.3.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=x86-64'
 /usr/local/libexec/gcc8/gcc/x86_64-portbld-freebsd12.0/8.3.0/collect2 -plugin /usr/local/libexec/gcc8/gcc/x86_64-portbld-freebsd12.0/8.3.0/liblto_plugin.so -plugin-opt=/usr/local/libexec/gcc8/gcc/x86_64-portbld-freebsd12.0/8.3.0/lto-wrapper -plugin-opt=-fresolution=/tmp//ccvnFRJD.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -m elf_x86_64_fbsd -V -dynamic-linker /libexec/ld-elf.so.1 /usr/lib/crt1.o /usr/lib/crti.o /usr/local/lib/gcc8/gcc/x86_64-portbld-freebsd12.0/8.3.0/crtbegin.o -L/usr/local/lib/gcc8/gcc/x86_64-portbld-freebsd12.0/8.3.0 -L/usr/local/lib/gcc8/gcc/x86_64-portbld-freebsd12.0/8.3.0/../../../../../x86_64-portbld-freebsd12.0/lib -L/usr/local/lib/gcc8/gcc/x86_64-portbld-freebsd12.0/8.3.0/../../.. /tmp//ccwd2t4G.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/local/lib/gcc8/gcc/x86_64-portbld-freebsd12.0/8.3.0/crtend.o /usr/lib/crtn.o
/usr/local/bin/ld: cannot find /usr/lib/libc_nonshared.a
/usr/local/bin/ld: cannot find /usr/lib/libssp_nonshared.a
collect2: error: ld returned 1 exit status

As I'm new to the bsd world, I thought I would have misconfigured something. So I've retested on naked system (just installation, tested before and after updating the system, no additional development packages installed)

> clang80 -v main.c
clang version 8.0.1 (tags/RELEASE_801/final)
Target: x86_64-portbld-freebsd12.0
Thread model: posix
InstalledDir: /usr/local/llvm80/bin
 "/usr/local/llvm80/bin/clang-8" -cc1 -triple x86_64-portbld-freebsd12.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name main.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -v -resource-dir /usr/local/llvm80/lib/clang/8.0.1 -fdebug-compilation-dir /usr/home/trident -ferror-limit 19 -fmessage-length 190 -fobjc-runtime=gnustep -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/main-ed1ce1.o -x c main.c -faddrsig
clang -cc1 version 8.0.1 based upon LLVM 8.0.1 default target x86_64-portbld-freebsd12.0
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/llvm80/lib/clang/8.0.1/include
 /usr/include
End of search list.
 "ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --hash-style=both --enable-new-dtags -o a.out /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib /tmp/main-ed1ce1.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o
clang-8: error: unable to execute command: Executable "ld" doesn't exist!
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)

I believe this is a bug, If a compiler is present, it should also work. If it is not intended to work, then maybe it should not be there, and installing a compiler should install as dependency all libraries for compiling a minimal program.

What should I install for being able to compile c and c++ programs? I could not find any package containing libc_nonshared and libssp_nonshared, those libraries do not seem to be present on trident, but are on freebsd.

Notice that on a minimal freebsd system cc was avaiable (it was on none of the tested trident systems) and I could build main.c without issues and without installing additional packages.

The C program is simply:

> cat main.c
int main(void) {
        return 0;
}
beanpole135 commented 5 years ago

You simply need to install the "os-generic-userland-devtools" package to get the entire compiler toolchain installed and setup.

fekir commented 5 years ago

@beanpole135

thank you, installing the os-generic-userland-devtools package fixed the issue, and also created cc.

Might I ask how one should have diagnosed the problem in order to understand what package he needed to install? I was not able to find any hint, and my experience with BSD systems is limited.

Also does it make sense for trident to have some program with broken dependencies installed by default? AFAIK the compiler is not usable, wouldn't it be better not having it at all?