On Sat, Feb 04, 2017 at 10:17:22AM +0100, Pascal Stumpf wrote:
> On Fri, 3 Feb 2017 22:52:41 +0100, Adam Wolk wrote:
> >
> >
> > Note in this case instead of substituting library name on the command line
> > it's
> > done in the source code itself with the {$linklib NAME} directive.
> >
> > I'm roughly looking for some feedback on what might cause such issue.
> > I think the proper solution is updating the hedgewars CMakeLists.txt in this
> > case to not use the XLAlua pascal flag and for this port baking it in with
> > a patch to the source. I am going to work on a diff like that for a separate
> > email including a hotfix for the -server package but I wanted to share the
> > actual problem this will remove in case someone can spot a bigger problem.
>
> Wow, thanks for investigating. I've taken a closer look at the binaries
> produced, and - lo and behold - when passing -XAfoo, fpc will generate a
> binary that is linked against /usr/libexec/ld.so twice, once as runtime
> linker, once as a shared object. Ugh. The fix is straightforward:
>
>
> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/lang/fpc/Makefile,v
> retrieving revision 1.13
> diff -u -p -r1.13 Makefile
> --- Makefile 7 May 2016 12:40:57 -0000 1.13
> +++ Makefile 4 Feb 2017 09:16:30 -0000
> @@ -7,7 +7,7 @@ COMMENT = open source compiler for Pasc
> V = 3.0.0
> DISTNAME = fpcbuild-${V}
> PKGNAME = fpc-${V}
> -REVISION = 1
> +REVISION = 2
> BOOT_GEN = 0
>
> CATEGORIES = lang
> Index: patches/patch-fpcsrc_compiler_systems_t_bsd_pas
> ===================================================================
> RCS file:
> /cvs/ports/lang/fpc/patches/patch-fpcsrc_compiler_systems_t_bsd_pas,v
> retrieving revision 1.3
> diff -u -p -r1.3 patch-fpcsrc_compiler_systems_t_bsd_pas
> --- patches/patch-fpcsrc_compiler_systems_t_bsd_pas 22 Dec 2015 14:43:55
> -0000 1.3
> +++ patches/patch-fpcsrc_compiler_systems_t_bsd_pas 4 Feb 2017 09:16:30
> -0000
> @@ -2,8 +2,10 @@ $OpenBSD: patch-fpcsrc_compiler_systems_
>
> Correct library search path for OpenBSD; always add -nopie to linker flags.
>
> +Do not link to /usr/libexec/ld.so as a shared library.
> +
> --- fpcsrc/compiler/systems/t_bsd.pas.orig Sun Dec 7 21:27:02 2014
> -+++ fpcsrc/compiler/systems/t_bsd.pas Thu Nov 26 15:17:06 2015
> ++++ fpcsrc/compiler/systems/t_bsd.pas Sat Feb 4 09:51:46 2017
> @@ -126,7 +126,10 @@ begin
> Inherited Create;
> if not Dontlinkstdlibpath Then
> @@ -12,11 +14,21 @@ Correct library search path for OpenBSD;
> + if not(target_info.system in systems_openbsd) then
> +
> LibrarySearchPath.AddPath(sysrootpath,'/lib;/usr/lib;/usr/X11R6/lib',true)
> + else
> -+
> LibrarySearchPath.AddPath(sysrootpath,'/usr/lib;/usr/X11R6/lib;${LOCALBASE}/lib',true)
> ++
> LibrarySearchPath.AddPath(sysrootpath,'/usr/lib;${X11BASE}/lib;${LOCALBASE}/lib',true)
> else
> { Mac OS X doesn't have a /lib }
> LibrarySearchPath.AddPath(sysrootpath,'/usr/lib',true)
> -@@ -697,8 +700,7 @@ begin
> +@@ -581,7 +584,8 @@ begin
> + { when we have -static for the linker the we also need libgcc }
> + if (cs_link_staticflag in current_settings.globalswitches) then
> + LinkRes.Add('-lgcc');
> +- if linkdynamic and (Info.DynamicLinker<>'') then
> ++ if linkdynamic and (Info.DynamicLinker<>'') and
> ++ not(target_info.system in systems_openbsd) then
> + LinkRes.AddFileName(Info.DynamicLinker);
> + if not LdSupportsNoResponseFile then
> + LinkRes.Add(')');
> +@@ -697,8 +701,7 @@ begin
> end;
>
> { Use -nopie on OpenBSD }
>
I just applied your diff, rebuilt lang/fpc and rebuild games/hedgewars using the
new compiler. The game now works. I was able to start a normal quickmatch
against the AI.
OK awolk@
>
>
> > PS.
> > While working on the port 2 things happened.
> >
> > 1. Upstream took some of our patches
> > http://hg.hedgewars.org/hedgewars/rev/ffc7bb9fde01
> > 2. The -server package didn't build for me and according to hedgewars
> > upstream
> > it's a ghc bug. FreeBSD ships a workaround patch for it
> >
> > https://svnweb.freebsd.org/ports/head/games/hedgewars/files/patch-CMakeLists.txt?revision=377852&view=markup
>
>
> Has this happened in any bulk build? If yes, we should take the fix.
>
Not that I know of but the diff removes a hardcoded -O2 passed to ghc.
The port in general hardcodes -O2 in a couple of places:
CMakeLists.txt
89:add_flag_append(CMAKE_C_FLAGS_RELEASE "-O2")
92:add_flag_append(CMAKE_CXX_FLAGS_RELEASE "-O2")
113:list(APPEND haskell_flags ${ghflags_parsed} "-O2")
cmake_modules/CMakePascalInformation.cmake
14:set(CMAKE_Pascal_FLAGS_RELEASE_INIT "-O2 -dNDEBUG")
15:set(CMAKE_Pascal_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -gl -gp")
cmake_modules/CMakePascalInformation.cmake.orig
14:set(CMAKE_Pascal_FLAGS_RELEASE_INIT "-O2 -dNDEBUG")
15:set(CMAKE_Pascal_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -gl -gp")
should we patch out the -O2 optimization regardless if bulks break?
>
> >
> > This problem manifests itself with the following compile error
> >
> > [25 of 25] Compiling Main (
> > /usr/local/pobj/hedgewars-src-0.9.22/hedgewars-src-0.9.22/gameServer/hedgewars-server.hs,
> > /usr/local/pobj/hedgewars-src-0.9.22/build-amd64/gameServer/Main.o )
> > *** Core Lint errors : in result of Simplifier ***
> > <no location info>: Warning:
> >
> >
> > [1]
> > https://www.reddit.com/r/openbsd_gaming/comments/5phgho/hedgewars/?st=iyq4oro0&sh=46dea45e
> > [2]
> > https://gist.github.com/mulander/b5aa0e825b88910c6d0e446db30dd526t
>