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

[OSX] undefined symbol _current_language #6070

Closed
DorpsGek opened this issue Jul 28, 2014 · 5 comments
Closed

[OSX] undefined symbol _current_language #6070

DorpsGek opened this issue Jul 28, 2014 · 5 comments
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

kernigh2 opened the ticket and wrote:

I have a PowerBook G4 with a PowerPC processor and Mac OS X 10.4.11 Tiger. The binary from openttd.org crashes on startup because of #5694. So I compiled my own binary.

When building OpenTTD 1.4.1, the linker can't link strgen because _current_language is an undefined symbol. My compiler is gcc 4.0.1 from Xcode 2.5.

The error happens because src/string.cpp contains code that uses _current_language. The definition of _current_language is in src/strings.cpp, which is not part of strgen. Because strgen uses _current_language but never defines it, the link fails. (This error slips through other compilers: I built OpenTTD 1.4.2-RC1 for OpenBSD without trouble. I guess that strgen only uses _current_language in an inline function, and nothing calls this function, so some compilers never emit the reference to _current_language.)

To fix this error, I edited src/string.cpp. I started with this patch from pkgsrc: http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/games/openttd/patches/patch-src_string.cpp?rev=1.1&content-type=text/x-cvsweb-markup&only_with_tag=MAIN

The patch from pkgsrc is for OpenTTD 1.3.2, but applies to 1.4.1. It adds a _current_collator to string.cpp # if defined(STRGEN) || defined(SETTINGSGEN). I added a _current_language to the same place. The patch that I attach now includes both _current_language and _current_collator.

To finish the build, I need both this patch and my other patch on #6069.

Attachments

Reported version: 1.4.1
Operating system: Mac OS X


This issue was imported from FlySpray: https://bugs.openttd.org/task/6070
@DorpsGek
Copy link
Member Author

Rubidium wrote:

I'm not sure what I must think of this bug report, or for that matter the patch at netbsd.

For now just focus on the netbsd patch; in language.h the declaration of _current_collator is guarded with an # ifdef, and in string.cpp the use of it is guarded by an # ifdef (on the same definition: WITH_ICU). The fix is furthermore to add the declaration, again, guarded by an # ifdef on WITH_ICU.

This would mean that something actually defines WITH_ICU in your, and the netbsd environment. Based on the code of our configure scripts it is as far as I can see impossible for WITH_ICU to end up in the definition at the command line.

Could you upload a configure log and build log, from a clean repository withe make VERBOSE:=1 ? Maybe this could shed some light on how WITH_ICU got defined. Otherwise, I would like to ask whether you can grep through your system's header files to find references to WITH_ICU.


This comment was imported from FlySpray: https://bugs.openttd.org/task/6070#comment13420

@DorpsGek
Copy link
Member Author

DorpsGek commented Aug 1, 2014

kernigh2 wrote:

My other computer runs OpenBSD, where I built OpenTTD 1.4.2-RC1 without patches. In this version, config.lib line 1752 has CFLAGS="$CFLAGS -DWITH_ICU", so OpenTTD put -DWITH_ICU in my CFLAGS. OpenTTD 1.4.1 and OpenTTD trunk (svn r26712) seem to define WITH_ICU in the same way. I have not saved any build logs, but both of my config logs show -DWITH_ICU in CFLAGS.

config.log from OpenBSD for unmodified OpenTTD 1.4.2-RC1: http://pastebin.com/ez3ezaG1

config.log from OS X for OpenTTD 1.4.1 plus patches: http://pastebin.com/iaUfWfXu

For OS X, I used NetBSD's pkgsrc to build OpenTTD and its dependencies (as I describe in a comment on #5694). I have private modifications to pkgsrc so it builds OpenTTD 1.4.1 (instead of an older version). When pkgsrc builds OpenTTD, it applies patches and adds several flags to ./configure, the compiler, and the linker.


This comment was imported from FlySpray: https://bugs.openttd.org/task/6070#comment13424

@DorpsGek
Copy link
Member Author

DorpsGek commented Aug 1, 2014

Rubidium wrote:

I'm missing the build log with "make VERBOSE:=1", however... if you are using the NetBSD patches, then this problem is caused by those patches.

As you can see from the config logs is that it creates two versions of CFLAGS (and friends); just a plain CFLAGS for building the openttd executable, and a CFLAGS_BUILD for the helper applications during build (they can even use a different compiler due to cross compiling). The CFLAGS_BUILD (and LDFLAGS_BUILD) do not contain any references to any of the libraries needed for OpenTTD, so no ICU, PNG, zlib, ....

In any case, the person making the NetBSD patches, in his/her wisdom, thought it would be useful to add CFLAGS to CFLAGS_BUILD, and as such try to link ICU, PNG, zlib and all kinds of other stuff into the helper applications. Furthermore, it includes defines that enable certain bits of code that should never be compiled into these helper applications.

Now, the NetBSD patch you linked that inspired your solution is just the NetBSD person trying to make the ill-patched build system yield a binary. However, this way of fixing something broken is not the right way.

I can only conclude that the patch is for fixing something that got broken by external patches, and as such this is no bug in our code.


This comment was imported from FlySpray: https://bugs.openttd.org/task/6070#comment13425

@DorpsGek
Copy link
Member Author

DorpsGek commented Aug 1, 2014

Rubidium closed the ticket.

Reason for closing: Unsupported custom version


This comment was imported from FlySpray: https://bugs.openttd.org/task/6070

@DorpsGek DorpsGek closed this as completed Aug 1, 2014
@DorpsGek
Copy link
Member Author

DorpsGek commented Aug 1, 2014

kernigh2 wrote:

Attaching the config.log and build.log from OS X for the Mercurial mirror of trunk (svn r26712). This build is outside of pkgsrc, but I am using the dependencies that pkgsrc built. There are no patches to OpenTTD; this is an unmodified trunk (now that trunk has the fix for #6069).

I saved build.log with:
gmake VERBOSE:=1 2>&1 | tee build.log

(On this Mac, "make" is GNU Make 3.80 and "gmake" is GNU Make 4.0, so either should work.)

This didn't reproduce the bug! It linked strgen and finished the build. (Then "gmake install" failed with "Cannot install the OSX Application Bundle", but I was able to run bin/openttd and play the game.)

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/6070#comment13426

@DorpsGek DorpsGek added Core flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant