Opened 8 years ago

Closed 7 years ago

#53433 closed defect (fixed)

wine, wine-devel, wine-crossover: Undefined symbols: "_strnlen"

Reported by: Umo022 (alancom2@yahoo.com) Owned by: ryandesign (Ryan Carsten Schmidt)
Priority: Normal Milestone:
Component: ports Version: 2.4.0
Keywords: snowleopard Cc: jyrkiwahlstedt, jeremyhu (Jeremy Huddleston Sequoia)
Port: wine, wine-devel, wine-crossover

Description

Latest update of MacPorts to 2.4.0 breaks the build of Wine 2.0 in Snow Leopard (MacOS 10.6.8). Looking at the log, there is an undefined symbol "_strnlen" from "_fx10_get_string" in file "effect.o".

Given that strnlen() is rather standard, maybe something broke in dependencies, or there is an incomplete LIB_PATH?

The relevant section of the log file is below:

:info:build make[1]: Entering directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_x11_wine/wine/work/wine-2.0/dlls/d3d10'
:info:build ../../tools/winegcc/winegcc -o d3d10.dll.so -B../../tools/winebuild -m32 -shared d3d10.spec d3d10_main.o \:info:build   effect.o shader.o stateblock.o utils.o version.res ../../dlls/dxgu
id/libdxguid.a \
:info:build   ../../dlls/uuid/libuuid.a -ld3d10core -ld3dcompiler -ldxgi ../../l
ibs/port/libwine_port.a \
:info:build   -L/opt/local/lib -Wl,-headerpad_max_install_names -framework CoreS
ervices -lz -arch i386
:info:build Undefined symbols:
:info:build   "_strnlen", referenced from:
:info:build       _fx10_get_string in effect.o
:info:build ld: symbol(s) not found
:info:build collect2: ld returned 1 exit status
:info:build winegcc: /usr/bin/gcc-4.2 failed
:info:build make[1]: *** [d3d10.dll.so] Error 2
:info:build make[1]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_x11_wine/wine/work/wine-2.0/dlls/d3d10'
:info:build make: *** [dlls/d3d10] Error 2
:info:build make: *** Waiting for unfinished jobs....:info:build make: Leaving directory `/opt/local/var/macports/build/_opt_local_va
r_macports_sources_rsync.macports.org_release_tarballs_ports_x11_wine/wine/work/
wine-2.0'
:info:build Command failed:  cd "/opt/local/var/macports/build/_opt_local_var_ma
cports_sources_rsync.macports.org_release_tarballs_ports_x11_wine/wine/work/wine
-2.0" && /usr/bin/make -j2 -w depend all 
:info:build Exit code: 2

Attachments (3)

wine_2_0_0_log.log (688.7 KB) - added by Umo022 (alancom2@yahoo.com) 8 years ago.
Log from failed Wine 2.0 build
wine-2.0-10.6.diff (1019 bytes) - added by chrisjogorman 8 years ago.
shader_missing_strnlen.log (1.5 MB) - added by Umo022 (alancom2@yahoo.com) 8 years ago.
shader.o missing strnlen()

Change History (17)

Changed 8 years ago by Umo022 (alancom2@yahoo.com)

Attachment: wine_2_0_0_log.log added

Log from failed Wine 2.0 build

comment:1 Changed 8 years ago by kencu (Ken)

There is no strnlen in snow leopard. However even after I fixed that, there are other errors that show up. Working on it.

Last edited 8 years ago by kencu (Ken) (previous) (diff)

comment:2 Changed 8 years ago by kencu (Ken)

OK. it was, in the end, just strnlen. Replacing that fixed the wine-2.0 build, and wine-2.0 seems to work correctly on brief testing with winemine and winefile.

port -v installed wine
The following ports are currently installed:
  wine @1.8.6_0 platform='darwin 10' archs='i386' date='2016-12-25T12:14:56-0800'
  wine @2.0_0 (active) platform='darwin 10' archs='i386' date='2017-01-29T12:41:26-0800'

as far as I can tell, these are the two files that need the definition added:

wine-2.0/dlls/d3d10/effect.c
wine-2.0/dlls/d3d11/shader.c

I used my strnlen override method to build it, though, saving the following file as /usr/local/include/string.h

#include "/usr/include/string.h"

#ifndef KENSTRINGLEN
#define KENSTRINGLEN

static inline size_t
strnlen(const char *s, size_t maxlen)
{
	size_t len;

	for (len = 0; len < maxlen; len++, s++) {
		if (!*s)
			break;
	}
	return (len);
}

#endif

A macports-acceptable fix might be to patch the strnlen definition into the two files I mentioned above. Or better yet, get the wine developers to add in a test for strnlen (that's actually the correct fix).

Wine-2.0 took about three hours to build, however, so I won't be building any patches today.

comment:3 Changed 8 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: jyrkiwahlstedt jeremyhu added; ryandesign removed
Keywords: snowleopard added
Owner: set to ryandesign
Port: wine-devel wine-crossover added
Status: newassigned
Summary: Wine 2.0 build failure in Snow Leopardwine, wine-devel, wine-crossover: Undefined symbols: "_strnlen"

This is an upstream issue and should be fixed there. Please provide any guidance to the wine developers here: https://bugs.winehq.org/show_bug.cgi?id=41220

comment:4 Changed 8 years ago by kencu (Ken)

OK, so no patches coming. The wine devs will fix it in due course -- Jeremy's previous bug report is spot-on, and identifies the same two files that I found, so they know what they have to do if they want to fix it.

In the meantime, you can build it on your own with the workaround I mentioned, if you want to. Don't forget to remove the file /usr/local/include/string.h after you build it or you'll run into other issues with other ports.

Changed 8 years ago by chrisjogorman

Attachment: wine-2.0-10.6.diff added

comment:5 Changed 8 years ago by chrisjogorman

There is a patch now at winehq for this bug. It came out the Feb 2.

comment:6 Changed 8 years ago by ryandesign (Ryan Carsten Schmidt)

Yes, but as it says there, the patch is not suitable for systems that already have strnlen. The developers of wine need to develop a proper solution.

comment:7 Changed 8 years ago by Umo022 (alancom2@yahoo.com)

Wine has now been updated to rev 2.0.1_0 and my previous patch for adding strnlen to effect.c and shader.c no longer work. "effect.o" is fixed by adding the strnlen() definition to it as before, but shader.c seems to have been completely rewritten and simply adding strnlen() to it fails as follows:

  1. Leaving shader.c unaltered results in "_strnlen() not found in call to shader_parse_signature".
  2. Forcibly adding strnlen() to shader.c results in "Duplicate symbol: _strnlen in effect.o and shader.o".

At first glance, shader.c seems to be a mass of macros. Of course, there is no actual obvious call to shader_parse_signature() to fix ... it's actually now defined in effect.c, so it'll take a more detailed examination of how shader.c is now doing this...

Attached is the log of adding strnlen() to effect.c, but not shader.c.

Changed 8 years ago by Umo022 (alancom2@yahoo.com)

Attachment: shader_missing_strnlen.log added

shader.o missing strnlen()

comment:8 Changed 8 years ago by kencu (Ken)

FYI, I built it on 10.6 using the string.h method above, which is much easier than patching, until it gets fixed (if it ever does).

comment:9 in reply to:  8 Changed 8 years ago by Umo022 (alancom2@yahoo.com)

Replying to kencu:

FYI, I built it on 10.6 using the string.h method above, which is much easier than patching, until it gets fixed (if it ever does).

I screwed up. I modified the shader.c in ../d3d10 instead of the one in ../d3d11. In attempting to back out of this, I did a

sudo port clean --work wine

which would clean up all intermediate working files, then a

sudo port upgrade wine

which would download the tarballs from the macports servers and rebuild from those sources. It should have failed as before, but with no version update that I'm aware of, it built just fine without my having to modify anything. At this point, I'm pretty confused.

... but wine 2.0.1 is working, and that's the important thing ...

comment:10 Changed 8 years ago by zoomosis

I ran into this problem today. I suspect the upstream folks haven't fixed it because they don't know what #ifdefs to use to support those OS X versions, although ideally their configure script should check for the presence of strnlen() and provide one if it's missing.

In the meantime, putting this

static size_t strnlen(const char *str, size_t max)
{
    const char *end = memchr (str, 0, max);
    return end ? (size_t)(end - str) : max;
}

in d3d10/effect.c and d3d11/shader.c is a temporary fix.

Note there are more errors further on in the build (on OS X 10.6 at least), but this should probably be in another thread:

cocoa_opengl.m:171: error: 'GL_DRAW_FRAMEBUFFER_BINDING' undeclared (first use in this function)

Version 1, edited 8 years ago by zoomosis (previous) (next) (diff)

comment:11 Changed 8 years ago by ryandesign (Ryan Carsten Schmidt)

configure scripts work by testing features. e.g. you test whether the strnlen function exists. If it doesn't, then you use a compatibility function. The developers of wine don't need to know which operating systems have this function, they just need to write the test.

comment:12 Changed 7 years ago by kencu (Ken)

Ryan, are you willing to have PortGroup snowleopard_fixes 1.0 added to the Portfile to fix this issue? It works well enough to resolve this issue locally if so.

comment:13 Changed 7 years ago by ryandesign (Ryan Carsten Schmidt)

Yes, please add it to all three ports; I forgot.

comment:14 Changed 7 years ago by kencu (Ken)

Resolution: fixed
Status: assignedclosed

In b99c9cd33348e5f4973a95a68785508c369d5ce2/macports-ports:

wine, wine-devel, wine-crossover: add snowleopard_fixes

closes: #53433

Note: See TracTickets for help on using tickets.