ponceto / xcpc-emulator

Xcpc - Amstrad CPC emulator for Linux, BSD, Unix [this repository is a mirror]
https://www.xcpc-emulator.net/
GNU General Public License v2.0
33 stars 3 forks source link

Compilation fails for 0.52.0 on FreeBSD 14.1-RELEASE (amd64) #2

Closed SanPollo closed 2 months ago

SanPollo commented 3 months ago

I am trying to compile the latest Xcpc release on FreeBSD 14.1. First of all I run the configure script like so:

./configure --includedir=/usr/local/include --libdir=/usr/local/lib

Then I run GNU make:

gmake -j$(nproc)

But unfortunately, it eventually fails with the following error:

amstrad/cpc/cpc-settings.cc:277:58: error: cannot pass object of non-trivial type 'std::string' (aka 'basic_string<char>') through variadic function; call will abort at runtime [-Wnon-pod-varargs]
  277 |         ::xcpc_log_debug("xcpc.settings.speedup   = %d", opt_speedup         );
      |                                                          ^

I get the same error using FreeBSD's native make, and with both gcc13 and gcc14.

Am I doing something wrong? Perhaps I need to pass more options to the compile script?

UPDATE: I get exactly the same error when using clang rather than gcc.

ponceto commented 3 months ago

Hi! Thank you for the report. It's clearly a programming error

You can delete this line cause it's just a debug line or replace %d with %s and add .c_str() to the operand.

I'll correct this when I'll return from vacation.

Sorry for the inconvenience

Thank you 👍

ponceto commented 3 months ago

I'll add an automatic freebsd builder to my CI to have a complete build. It's weird my linux build didn't throw such programming error

SanPollo commented 3 months ago

Thank you. I'm not sure what the issue could be. The version of Xcpc in the ports tree is very old, and I contacted the port maintainer, who said he hasn't used FreeBSD for years. I am considering taking over the responsibility from him if I can get Xcpc to build.

ponceto commented 3 months ago

Oh great to hear!!

I'll build a 0.52.1 when I'll come back from vacations (in ~2 weeks) with the fix and I'll keep you in touch.

If you want to build Xcpc, just drop the line 277 as I said just before. It'll build fine (if there's no another bug like this).

If you encounter another bug, please let me know.

As I said, I'll add a specific FreeBSD runner in my gitlab CI to avoid such a thing in the furure.

ponceto commented 2 months ago

Hi @SanPollo!

The problem is fixed. Can you test this archive? If everything is okay after your build, I'll do a new release.

xcpc-0.0.0.tar.gz

SanPollo commented 2 months ago

@ponceto thank you very much. The archive builds fine on gcc13 and gcc14. I did notice some strange behaviour though; I had gcc12, gcc13 and gcc14 installed, and I first tried building with gcc13. Although the build finished fine, when I ran xcpc, I got the following:

ld-elf.so.1: /usr/local/lib/gcc12/libstdc++.so.6: version GLIBCXX_3.4.32 required by /usr/local/bin/xcpc not found

I uninstalled gcc12, and tried the build in gcc14. I then got a similar error, this time pointing to the same library in /usr/local/lib/gcc13. I checked the pkg-message for gcc14 and it says the following:

To ensure binaries built with this toolchain find appropriate versions
of the necessary run-time libraries, you may want to link using

  -Wl,-rpath=/usr/local/lib/gcc14

In the end I just uninstalled gcc12 and gcc14 as I didn't have any dependencies on them, built xcpc against gcc13, and it ran fine.

But, it's not unheard of for FreeBSD installations to have multiple versions of gcc installed. Are the linking options mentioned in the pkg-message something you can specify in the Makefile? If so, would you be able to specify gcc14 as it is the latest stable version?

ponceto commented 2 months ago

It's because you have many differents versions of toolchains on your system. In this case you must adjust LDFLAGS and/or LD_LIBRARY_FLAGS before running configure to instruct the linker what choice it should make.

ponceto commented 2 months ago

If you want more than one toolchain, I recommand you to use VM or jails ton isolate each toolchain and avoid such problems

SanPollo commented 2 months ago

When I get around to learning how to create ports, I will play around with that linking option. Many thanks for all your help - xcpc is now working fine!

ponceto commented 2 months ago

New release, v0.52.1.

https://www.xcpc-emulator.net/posts/2024/09/08/xcpc-0.52.1-has-been-released.html