Re: Fix libexec/ld.so/dlclose regress

2017-08-03 Thread Ted Unangst
Joerg Sonnenberger wrote:
> On Wed, Aug 02, 2017 at 09:03:30PM +0200, Mark Kettenis wrote:
> > Couldn't convince clang not to inline duplicateFun() into bbTest2().
> > Splitting things out in a seperate file avoids the issue.  Fixes the
> > regression test.
> 
> Have you tried the combiniation of noinline attribute with
>   asm volatile("":::"memory")
> as non-movable side effect?

That's not representative of how libc is coded, though. If we rely on separate
translation units for the feature to work, that's how the test should work
too.



Re: Fix libexec/ld.so/dlclose regress

2017-08-03 Thread Joerg Sonnenberger
On Wed, Aug 02, 2017 at 09:03:30PM +0200, Mark Kettenis wrote:
> Couldn't convince clang not to inline duplicateFun() into bbTest2().
> Splitting things out in a seperate file avoids the issue.  Fixes the
> regression test.

Have you tried the combiniation of noinline attribute with
  asm volatile("":::"memory")
as non-movable side effect?

Joerg



Fix libexec/ld.so/dlclose regress

2017-08-02 Thread Mark Kettenis
Couldn't convince clang not to inline duplicateFun() into bbTest2().
Splitting things out in a seperate file avoids the issue.  Fixes the
regression test.

ok?


Index: regress/libexec/ld.so/dlclose/test1/libbb/Makefile
===
RCS file: /cvs/src/regress/libexec/ld.so/dlclose/test1/libbb/Makefile,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 Makefile
--- regress/libexec/ld.so/dlclose/test1/libbb/Makefile  28 Sep 2005 15:42:32 
-  1.1.1.1
+++ regress/libexec/ld.so/dlclose/test1/libbb/Makefile  2 Aug 2017 18:59:14 
-
@@ -1,7 +1,7 @@
 #  $OpenBSD: Makefile,v 1.1.1.1 2005/09/28 15:42:32 kurt Exp $
 
 LIB=   bb
-SRCS=  bb.c
+SRCS=  bb.c bbb.c
 
 regress: all
 
Index: regress/libexec/ld.so/dlclose/test1/libbb/bb.c
===
RCS file: /cvs/src/regress/libexec/ld.so/dlclose/test1/libbb/bb.c,v
retrieving revision 1.2
diff -u -p -r1.2 bb.c
--- regress/libexec/ld.so/dlclose/test1/libbb/bb.c  30 Sep 2005 14:57:35 
-  1.2
+++ regress/libexec/ld.so/dlclose/test1/libbb/bb.c  2 Aug 2017 18:59:14 
-
@@ -20,19 +20,10 @@
 #include 
 #include 
 
-int bbSymbol;
-
-void
-bbLazyFun()
-{
+extern void bbLazyFun();
+extern int duplicateFun();
 
-}
-
-int
-duplicateFun()
-{
-   return (1);
-}
+int bbSymbol;
 
 int
 bbTest1()
Index: regress/libexec/ld.so/dlclose/test1/libbb/bbb.c
===
RCS file: regress/libexec/ld.so/dlclose/test1/libbb/bbb.c
diff -N regress/libexec/ld.so/dlclose/test1/libbb/bbb.c
--- /dev/null   1 Jan 1970 00:00:00 -
+++ regress/libexec/ld.so/dlclose/test1/libbb/bbb.c 2 Aug 2017 18:59:14 
-
@@ -0,0 +1,30 @@
+/* $OpenBSD$   */
+
+/*
+ * Copyright (c) 2005 Kurt Miller 
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+void
+bbLazyFun()
+{
+
+}
+
+int
+duplicateFun()
+{
+   return (1);
+}