randyrossi / bmc64

A bare metal Commodore 64 emulator for the Raspberry Pi with true 50hz/60hz smooth scrolling, low input latency and better audio/video sync.
GNU General Public License v3.0
479 stars 56 forks source link

build failure -- multiple undefined references: memcpy, strrchr, strlen, etc #147

Open jamincollins opened 3 years ago

jamincollins commented 3 years ago

I have tried building on both Arch Linux and Ubuntu 20.04. On both systems I have also tried both of the following toolchains:

In all cases, the builds fail with the following error:

...
==============================================================
Link errors above are expected
==============================================================
rm -f *.o *.a *.elf *.lst *.img *.hex *.cir *.map *~ 
  CPP   main.o
  CPP   kernel.o
  CPP   vicesound.o
  CPP   vicesoundbasedevice.o
vicesoundbasedevice.cpp: In member function 'void ViceSoundBaseDevice::Callback(VCHI_CALLBACK_REASON_T, void*)':
vicesoundbasedevice.cpp:413:32: warning: comparison of integer expressions of different signedness: 'uint32_t' {aka 'long unsigned int'} and 'int32_t' {aka 'long int'} [-Wsign-compare]
  413 |     if (Msg.u.complete.cookie1 != VC_AUDIO_WRITE_COOKIE1 ||
vicesoundbasedevice.cpp:414:32: warning: comparison of integer expressions of different signedness: 'uint32_t' {aka 'long unsigned int'} and 'int32_t' {aka 'long int'} [-Wsign-compare]
  414 |         Msg.u.complete.cookie2 != VC_AUDIO_WRITE_COOKIE2) {
  CPP   viceoptions.o
  CPP   viceapp.o
  CPP   fbl.o
  CC    crt_pi_idx.o
  CC    crt_pi_rgb.o
  CPP   viceemulatorcore.o
In file included from third_party/vice-3.3/src/types.h:30,
                 from third_party/vice-3.3/src/sid/sid.h:34,
                 from viceemulatorcore.cpp:31:
third_party/vice-3.3/src/vice.h:43:12: fatal error: config.h: No such file or directory
   43 | #  include <config.h> /* Automagically created by the `configure' script.  */
      |            ^~~~~~~~~~
compilation terminated.
make: *** [third_party/circle-stdlib/libs/circle/Rules.mk:133: viceemulatorcore.o] Error 1

The bmc64 repository and toolchain are under /opt.

I'm using the following build logic:

#!/bin/bash
set -euo pipefail

export ARM_HOME=$(find /opt -maxdepth 1 -type d | grep gcc)
export PATH=$PATH:$ARM_HOME/bin
export ARM_VERSION=$(ls ${ARM_HOME}/lib/gcc/arm-none-eabi/)

env | grep ARM
read

./clean_all.sh || true

./make_all.sh ${@}
./make_machines.sh ${@}

An example of the settings made by the above:

ARM_VERSION=9.2.1
ARM_HOME=/opt/gcc-arm-none-eabi-9-2019-q4-major

Submodule status:

# git submodule status --recursive
 49fddf66e49f48c6368c477ed54e31c463100fff third_party/circle-stdlib (v8.0-24-g49fddf6)
 fe24b6bebd1532f2a0ee981af12eaf50cc9e97fb third_party/circle-stdlib/libs/circle (Step40)
 28aaa63ac6954d1e61706540590303f29e74f96c third_party/circle-stdlib/libs/circle/addon/littlevgl/lv_examples (v6.0)
 135c119b204df48daf36bd1d014e1a8348286aa5 third_party/circle-stdlib/libs/circle/addon/littlevgl/lvgl (v6.0)
 c01f95bcb08278d9e00f9795c7641284d4f89931 third_party/circle-stdlib/libs/circle-newlib (cygwin-3_0_4-release-313-gc01f95bcb)
 d81c11b8ab61fd5b2da8133aa73c5fe33a0633eb third_party/circle-stdlib/libs/mbedtls (mbedtls-2.16.2)
randyrossi commented 3 years ago

If config.h was not created, it means the configure step for VICE did not work. You'll have to look earlier in the log to see what went wrong.

On Sat, Dec 5, 2020 at 9:55 PM Jamin Collins notifications@github.com wrote:

I have tried building on both Arch Linux and Ubuntu 20.04. On both systems I have also tried both of the following toolchains:

  • gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2
  • gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2

In all cases, the builds fail with the following error:

...

Link errors above are expected

rm -f .o .a .elf .lst .img .hex .cir .map ~ CPP main.o CPP kernel.o CPP vicesound.o CPP vicesoundbasedevice.o vicesoundbasedevice.cpp: In member function 'void ViceSoundBaseDevice::Callback(VCHI_CALLBACK_REASON_T, void)': vicesoundbasedevice.cpp:413:32: warning: comparison of integer expressions of different signedness: 'uint32_t' {aka 'long unsigned int'} and 'int32_t' {aka 'long int'} [-Wsign-compare] 413 | if (Msg.u.complete.cookie1 != VC_AUDIO_WRITE_COOKIE1 || vicesoundbasedevice.cpp:414:32: warning: comparison of integer expressions of different signedness: 'uint32_t' {aka 'long unsigned int'} and 'int32_t' {aka 'long int'} [-Wsign-compare] 414 | Msg.u.complete.cookie2 != VC_AUDIO_WRITE_COOKIE2) { CPP viceoptions.o CPP viceapp.o CPP fbl.o CC crt_pi_idx.o CC crt_pi_rgb.o CPP viceemulatorcore.o In file included from third_party/vice-3.3/src/types.h:30, from third_party/vice-3.3/src/sid/sid.h:34, from viceemulatorcore.cpp:31: third_party/vice-3.3/src/vice.h:43:12: fatal error: config.h: No such file or directory 43 | # include / Automagically created by the `configure' script. / | ^~~~~~ compilation terminated. make: *** [third_party/circle-stdlib/libs/circle/Rules.mk:133: viceemulatorcore.o] Error 1

The bmc64 repository and toolchain are under /opt.

I'm using the following build logic:

!/bin/bash

set -euo pipefail

export ARM_HOME=$(find /opt -maxdepth 1 -type d | grep gcc) export PATH=$PATH:$ARM_HOME/bin export ARM_VERSION=$(ls ${ARM_HOME}/lib/gcc/arm-none-eabi/)

env | grep ARM read

./clean_all.sh || true

./make_all.sh ${@} ./make_machines.sh ${@}

An example of the settings made by the above:

ARM_VERSION=9.2.1 ARM_HOME=/opt/gcc-arm-none-eabi-9-2019-q4-major

Submodule status:

git submodule status --recursive

49fddf66e49f48c6368c477ed54e31c463100fff third_party/circle-stdlib (v8.0-24-g49fddf6) fe24b6bebd1532f2a0ee981af12eaf50cc9e97fb third_party/circle-stdlib/libs/circle (Step40) 28aaa63ac6954d1e61706540590303f29e74f96c third_party/circle-stdlib/libs/circle/addon/littlevgl/lv_examples (v6.0) 135c119b204df48daf36bd1d014e1a8348286aa5 third_party/circle-stdlib/libs/circle/addon/littlevgl/lvgl (v6.0) c01f95bcb08278d9e00f9795c7641284d4f89931 third_party/circle-stdlib/libs/circle-newlib (cygwin-3_0_4-release-313-gc01f95bcb) d81c11b8ab61fd5b2da8133aa73c5fe33a0633eb third_party/circle-stdlib/libs/mbedtls (mbedtls-2.16.2)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/randyrossi/bmc64/issues/147, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI3HKBNVBSZOTGMTWYJBDTSTLXCDANCNFSM4UO7ZKGQ .

-- Randy Rossi

jamincollins commented 3 years ago

Digging into this, it appears there are a few issues.

The build scripts don't exit on first error.

After I set the build scripts to exit on error I found the way the source tree is being patched actually errors. This was fixed by using git apply instead of patch, given that the diff being applied appears to be a git diff.

I then found that the build instructions don't appear to list all required packages for building on a fresh install. So far, I've found bison and flex to be required in addition to those listed.

At this point the build is failing with:

...
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: filter.cc:(.text+0xe40): undefined reference to `operator delete[](void*)'
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: filter.cc:(.text+0x1110): undefined reference to `log1p'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:1938: x64] Error 1
make: *** [Makefile:919: x64] Error 2

Lines leading up to first undefined reference:

making all in video
Making all in raspi
Making all in c64
Making all in vic20
Making all in c128
Making all in plus4
Making all in pet
Making all in shared
making all in monitor
making all in diskimage
making all in iecbus
making all in serial
making all in fsdevice
making all in tape
making all in imagecontents
making all in fileio
making all in core
making librtc.a in rtc
making all in userport
making all in tapeport
making all in hvsc
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: ../src/arch/raspi/libarch.a(archdep.o): in function `archdep_program_name':
archdep.c:(.text+0x8): multiple definition of `archdep_program_name'; ../src/arch/shared/libarchdep.a(archdep_program_name.o):archdep_program_name.c:(.text+0x0): first defined here
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: ../src/arch/raspi/libarch.a(archdep.o): in function `archdep_boot_path':
archdep.c:(.text+0x40): multiple definition of `archdep_boot_path'; ../src/arch/shared/libarchdep.a(archdep_boot_path.o):archdep_boot_path.c:(.text+0x0): first defined here
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: ../src/arch/raspi/libarch.a(archdep.o): in function `archdep_default_sysfile_pathlist':
archdep.c:(.text+0x4c): multiple definition of `archdep_default_sysfile_pathlist'; ../src/arch/shared/libarchdep.a(archdep_default_sysfile_pathlist.o):archdep_default_sysfile_pathlist.c:(.text+0x0): first defined here
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: ../src/arch/raspi/libarch.a(archdep.o): in function `archdep_make_backup_filename':
archdep.c:(.text+0xbc): multiple definition of `archdep_make_backup_filename'; ../src/arch/shared/libarchdep.a(archdep_make_backup_filename.o):archdep_make_backup_filename.c:(.text+0x0): first defined here
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: ../src/arch/raspi/libarch.a(archdep.o): in function `archdep_default_fliplist_file_name':
archdep.c:(.text+0xe4): multiple definition of `archdep_default_fliplist_file_name'; ../src/arch/shared/libarchdep.a(archdep_default_fliplist_file_name.o):archdep_default_fliplist_file_name.c:(.text+0x0): first defined here
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: ../src/arch/raspi/libarch.a(archdep.o): in function `archdep_default_autostart_disk_image_file_name':
archdep.c:(.text+0x168): multiple definition of `archdep_default_autostart_disk_image_file_name'; ../src/arch/shared/libarchdep.a(archdep_default_autostart_disk_image_file_name.o):archdep_default_autostart_disk_image_file_name.c:(.text+0x0): first defined here
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: ../src/arch/raspi/libarch.a(archdep.o): in function `archdep_open_default_log_file':
archdep.c:(.text+0x1a4): multiple definition of `archdep_open_default_log_file'; ../src/arch/shared/libarchdep.a(archdep_open_default_log_file.o):archdep_open_default_log_file.c:(.text+0x0): first defined here
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: ../src/arch/raspi/libarch.a(archdep.o): in function `archdep_path_is_relative':
archdep.c:(.text+0x214): multiple definition of `archdep_path_is_relative'; ../src/arch/shared/libarchdep.a(archdep_path_is_relative.o):archdep_path_is_relative.c:(.text+0x0): first defined here
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: ../src/arch/raspi/libarch.a(archdep.o): in function `archdep_expand_path':
archdep.c:(.text+0x24c): multiple definition of `archdep_expand_path'; ../src/arch/shared/libarchdep.a(archdep_expand_path.o):archdep_expand_path.c:(.text+0x0): first defined here
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: ../src/arch/raspi/libarch.a(archdep.o): in function `archdep_startup_log_error':
archdep.c:(.text+0x2ac): multiple definition of `archdep_startup_log_error'; ../src/arch/shared/libarchdep.a(archdep_startup_log_error.o):archdep_startup_log_error.c:(.text+0x0): first defined here
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: ../src/arch/raspi/libarch.a(archdep.o): in function `archdep_quote_parameter':
archdep.c:(.text+0x2e8): multiple definition of `archdep_quote_parameter'; ../src/arch/shared/libarchdep.a(archdep_quote_parameter.o):archdep_quote_parameter.c:(.text+0x0): first defined here
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: ../src/arch/raspi/libarch.a(archdep.o): in function `archdep_filename_parameter':
archdep.c:(.text+0x2ec): multiple definition of `archdep_filename_parameter'; ../src/arch/shared/libarchdep.a(archdep_filename_parameter.o):archdep_filename_parameter.c:(.text+0x0): first defined here
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: ../src/arch/raspi/libarch.a(archdep.o): in function `archdep_tmpnam':
archdep.c:(.text+0x310): multiple definition of `archdep_tmpnam'; ../src/arch/shared/libarchdep.a(archdep_tmpnam.o):archdep_tmpnam.c:(.text+0x0): first defined here
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: ../src/arch/raspi/libarch.a(archdep.o): in function `archdep_mkdir':
archdep.c:(.text+0x354): multiple definition of `archdep_mkdir'; ../src/arch/shared/libarchdep.a(archdep_mkdir.o):archdep_mkdir.c:(.text+0x0): first defined here
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: ../src/arch/raspi/libarch.a(archdep.o): in function `archdep_rmdir':
archdep.c:(.text+0x374): multiple definition of `archdep_rmdir'; ../src/arch/shared/libarchdep.a(archdep_rmdir.o):archdep_rmdir.c:(.text+0x0): first defined here
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: ../src/arch/raspi/libarch.a(archdep.o): in function `archdep_stat':
archdep.c:(.text+0x394): multiple definition of `archdep_stat'; ../src/arch/shared/libarchdep.a(archdep_stat.o):archdep_stat.c:(.text+0x0): first defined here
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: ../src/arch/raspi/libarch.a(archdep.o): in function `archdep_rename':
archdep.c:(.text+0x4d4): multiple definition of `archdep_rename'; ../src/arch/shared/libarchdep.a(archdep_rename.o):archdep_rename.c:(.text+0x0): first defined here
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: ../src/arch/raspi/libarch.a(archdep.o): in function `archdep_vice_exit':
archdep.c:(.text+0x4f8): multiple definition of `archdep_vice_exit'; ../src/arch/shared/libarchdep.a(archdep_atexit.o):archdep_atexit.c:(.text+0x4): first defined here
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: ../src/arch/raspi/libarch.a(archdep.o): in function `archdep_vice_atexit':
archdep.c:(.text+0x4fc): multiple definition of `archdep_vice_atexit'; ../src/arch/shared/libarchdep.a(archdep_atexit.o):archdep_atexit.c:(.text+0x0): first defined here
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: warning: cannot find entry symbol _start; defaulting to 0000000000008000
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: attach.o: in function `file_system_attach_disk_internal':
attach.c:(.text+0x1c8): undefined reference to `memcpy'
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: autostart.o: in function `autostart_disk':
autostart.c:(.text+0x155c): undefined reference to `memcpy'
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: autostart.o: in function `autostart_autodetect_opt_prgname':
autostart.c:(.text+0x1a04): undefined reference to `strrchr'
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: autostart.c:(.text+0x1a24): undefined reference to `strrchr'
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: autostart-prg.o: in function `autostart_prg_with_disk_image':
autostart-prg.c:(.text+0x4a8): undefined reference to `strlen'
maitrezoid commented 3 years ago

Hello. I have the same problem. I think config.h is not generated by the configure script in vice. When i use configure directly i have this error

checking mpg123.h presence... no checking for mpg123.h... no checking for OpenCBM support... yes checking that generated files are newer than configure... done configure: error: conditional "RASPI_COMPILE" was never defined. Usually this means the macro was only invoked conditionally.

And here i don't know what to do.

rhester72 commented 3 years ago

When you clone in git, you are doing --recursive, right?

randyrossi commented 3 years ago

Yes

On Tue, Jan 19, 2021 at 1:32 PM rhester72 notifications@github.com wrote:

When you clone in git, you are doing --recursive, right?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/randyrossi/bmc64/issues/147#issuecomment-763037964, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI3HKC3LJ7S7BY234AUC53S2XF3LANCNFSM4UO7ZKGQ .

-- Randy Rossi

rhester72 commented 3 years ago

One last thing to try...make sure PREFIX is set properly. Do this:

export PREFIX=arm-none-eabi- ./clean_all.sh ./make_all.sh ...

fearthecowboy commented 2 years ago

[Edited] -- I was running into this same problem.

Fresh OS, followed building.md exactly (and added bison and flex to the sudo apt install ... )

It would seem that the build really does require a very specific arm toolset -- gcc-arm-none-eabi-7-2018-q2-update

What I did on a brand new OS install:

# home folder
cd ~

# install prereq's 
sudo apt-get install git build-essential automake autoconf libtool pkg-config autoconf-archive autotools-dev flex bison xa65 -y

# download the ARM toolset
curl -L "https://developer.arm.com/-/media/Files/downloads/gnu-rm/7-2018q2/gcc-arm-none-eabi-7-2018-q2-update-linux.tar.bz2?revision=bc2c96c0-14b5-4bb4-9f18-bceb4050fee7?product=GNU%20Arm%20Embedded%20Toolchain,64-bit,,Linux,7-2018-q2-update" -o gcc-arm-none-eabi-7-2018-q2-update-linux.tar.bz2

# unpack ARM 
tar xvf gcc-arm-none-eabi-7-2018-q2-update-linux.tar.bz2

# set up the environment
export ARM_HOME=~/gcc-arm-none-eabi-7-2018-q2-update
export PATH=$ARM_HOME/bin:$PATH
export ARM_VERSION=7.3.1
export PREFIX=arm-none-eabi-

# clone the repo
git clone https://github.com/randyrossi/bmc64.git --recursive

# project
cd bmc64

# clean first 
./clean_all.sh

# make the third party libraries and kernel (this will have some linker errors, it says that's ok...)
./make_all.sh pi3

# make the kernels for the machines.
./make_machines.sh pi3

and I get:

image
rhester72 commented 2 years ago

@fearthecowboy Your compile was successful. What's the concern? (You will want to replace kernel8-32.img with kernel8-32.img.c64)

fearthecowboy commented 2 years ago

Ah, I should have said I was running into the same problem, when I was using the latest arm tools. I backed down to the 2018-q2 version, and the problems went away.

(Which I wanted to post, so that if someone else ran into it, they knew what the fix was). The build fails with 2020- versions of the ARM toolset.