[Bug 214258] devel/openmp: spurious libm dependency

2016-11-05 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214258

Bug ID: 214258
   Summary: devel/openmp: spurious libm dependency
   Product: Ports & Packages
   Version: Latest
  Hardware: Any
OS: Any
Status: New
  Keywords: needs-patch
  Severity: Affects Only Me
  Priority: ---
 Component: Individual Port(s)
  Assignee: b...@freebsd.org
  Reporter: jbe...@freebsd.org
CC: freebsd-toolchain@FreeBSD.org
 Flags: maintainer-feedback?(b...@freebsd.org)
  Assignee: b...@freebsd.org

LLVM openmp picks up math symbols despite not using them in any of its object
files.

$ cd /usr/ports/devel/openmp
$ make install
$ cd $(make -V WRKSRC)

$ fgrep -lr scalbnl .
./runtime/src/libgomp.so
./runtime/src/libiomp5.so
./runtime/src/libomp.so
./runtime/exports/lin_32e/lib/libomp.so

$ echo 'int main() { }' | cc ./runtime/src/libomp.so -xc -
./runtime/src/libomp.so: undefined reference to `scalbnl'
./runtime/src/libomp.so: undefined reference to `fmaxl'
./runtime/src/libomp.so: undefined reference to `logbl'
./runtime/src/libomp.so: undefined reference to `scalbnf'
./runtime/src/libomp.so: undefined reference to `logb'
./runtime/src/libomp.so: undefined reference to `logbf'
./runtime/src/libomp.so: undefined reference to `scalbn'
cc: error: linker command failed with exit code 1 (use -v to see invocation)

$ echo 'int main() { }' | cc -fopenmp -L/usr/local/lib -xc -
/usr/local/lib/libomp.so: undefined reference to `scalbnl'
/usr/local/lib/libomp.so: undefined reference to `fmaxl'
/usr/local/lib/libomp.so: undefined reference to `logbl'
/usr/local/lib/libomp.so: undefined reference to `scalbnf'
/usr/local/lib/libomp.so: undefined reference to `logb'
/usr/local/lib/libomp.so: undefined reference to `logbf'
/usr/local/lib/libomp.so: undefined reference to `scalbn'
cc: error: linker command failed with exit code 1 (use -v to see invocation)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
freebsd-toolchain@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


[Bug 214258] devel/openmp: spurious libm dependency

2016-11-05 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214258

Jan Beich (mail not working)  changed:

   What|Removed |Added

 CC||b...@freebsd.org
   Assignee|b...@freebsd.org|freebsd-toolchain@FreeBSD.o
   ||rg

--- Comment #1 from Jan Beich (mail not working)  ---
Assigning to toolchain@ in order to help bisecting base change. It affects
11.0+ but not 10.3 or 9.3.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
___
freebsd-toolchain@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


[Bug 214258] devel/openmp: spurious libm dependency

2017-01-25 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214258

Yuta Satoh  changed:

   What|Removed |Added

 CC||nigoro@gmail.com

--- Comment #2 from Yuta Satoh  ---
Created attachment 179304
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=179304&action=edit
ports/devel/openmp/files/patch-link-libm.patch

Sample patch for devel/openmp-3.9.0.

The attached patch links libm.
-Wl,--no-as-needed is necessary for forced linking.


Before applying the patch)
# ldd /usr/local/lib/libomp.so
/usr/local/lib/libomp.so:
libthr.so.3 => /lib/libthr.so.3 (0x801288000)
libc.so.7 => /lib/libc.so.7 (0x800823000)

After applying the patch)
# ldd /usr/local/lib/libomp.so
/usr/local/lib/libomp.so:
libm.so.5 => /lib/libm.so.5 (0x801288000)
libthr.so.3 => /lib/libthr.so.3 (0x8014b3000)
libc.so.7 => /lib/libc.so.7 (0x800823000)


$ echo 'int main() { }' | cc -fopenmp -L/usr/local/lib -xc - -v
FreeBSD clang version 3.8.0 (tags/RELEASE_380/final 262564) (based on LLVM
3.8.0)
Target: x86_64-unknown-freebsd11.0
Thread model: posix
InstalledDir: /usr/bin
 "/usr/bin/cc" -cc1 -triple x86_64-unknown-freebsd11.0 -emit-obj -mrelax-all
-disable-free -disable-llvm-verifier -main-file-name - -mrelocation-model
static -mthread-model posix -mdisable-fp-elim -masm-verbose
-mconstructor-aliases -munwind-tables -target-cpu x86-64 -v -dwarf-column-info
-debugger-tuning=gdb -resource-dir /usr/bin/../lib/clang/3.8.0
-fdebug-compilation-dir /usr/home/nigoro -ferror-limit 19 -fmessage-length 172
-fopenmp -fobjc-runtime=gnustep -fdiagnostics-show-option -fcolor-diagnostics
-o /tmp/--26d632.o -x c -
clang -cc1 version 3.8.0 based upon LLVM 3.8.0 default target
x86_64-unknown-freebsd11.0
#include "..." search starts here:
#include <...> search starts here:
 /usr/bin/../lib/clang/3.8.0/include
 /usr/include
End of search list.
 "/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1
--hash-style=both --enable-new-dtags -o a.out /usr/lib/crt1.o /usr/lib/crti.o
/usr/lib/crtbegin.o -L/usr/local/lib -L/usr/lib /tmp/--26d632.o -lomp -lgcc
--as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed
/usr/lib/crtend.o /usr/lib/crtn.o

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
___
freebsd-toolchain@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


[Bug 214258] devel/openmp: spurious libm dependency

2017-03-15 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214258

--- Comment #3 from Jan Beich (mail not working)  ---
To avoid maintenance burden it'd be nice if we fix base system regression
before FreeBSD 11.1-RELEASE. devel/openmp isn't the only -lomp provider.

$ fetch https://computing.llnl.gov/tutorials/openMP/samples/C/omp_hello.c

$ pkg install llvm37 llvm38 llvm39 llvm40 llvm-devel

$ find -s /usr/local -name libomp.so
/usr/local/lib/libomp.so
/usr/local/llvm-devel/lib/libomp.so
/usr/local/llvm37/lib/libomp.so
/usr/local/llvm38/lib/libomp.so
/usr/local/llvm39/lib/libomp.so
/usr/local/llvm40/lib/libomp.so

$ clang37 -fopenmp omp_hello.c
/usr/bin/ld: cannot find -lomp
clang-3.7: error: linker command failed with exit code 1 (use -v to see
invocation)

$ clang37 -fopenmp omp_hello.c $(llvm-config37 --ldflags)
/usr/local/llvm37/lib/libomp.so: undefined reference to `scalbnl'
/usr/local/llvm37/lib/libomp.so: undefined reference to `fmaxl'
/usr/local/llvm37/lib/libomp.so: undefined reference to `logbl'
/usr/local/llvm37/lib/libomp.so: undefined reference to `scalbnf'
/usr/local/llvm37/lib/libomp.so: undefined reference to `logb'
/usr/local/llvm37/lib/libomp.so: undefined reference to `logbf'
/usr/local/llvm37/lib/libomp.so: undefined reference to `scalbn'
clang-3.7: error: linker command failed with exit code 1 (use -v to see
invocation)

$ clang38 -fopenmp omp_hello.c
/usr/local/llvm38/lib/libomp.so: undefined reference to `scalbnl'
/usr/local/llvm38/lib/libomp.so: undefined reference to `fmaxl'
/usr/local/llvm38/lib/libomp.so: undefined reference to `logbl'
/usr/local/llvm38/lib/libomp.so: undefined reference to `scalbnf'
/usr/local/llvm38/lib/libomp.so: undefined reference to `logb'
/usr/local/llvm38/lib/libomp.so: undefined reference to `logbf'
/usr/local/llvm38/lib/libomp.so: undefined reference to `scalbn'
clang-3.8: error: linker command failed with exit code 1 (use -v to see
invocation)

$ clang39 -fopenmp omp_hello.c
/usr/local/llvm39/lib/libomp.so: undefined reference to `scalbnl'
/usr/local/llvm39/lib/libomp.so: undefined reference to `fmaxl'
/usr/local/llvm39/lib/libomp.so: undefined reference to `logbl'
/usr/local/llvm39/lib/libomp.so: undefined reference to `scalbnf'
/usr/local/llvm39/lib/libomp.so: undefined reference to `logb'
/usr/local/llvm39/lib/libomp.so: undefined reference to `logbf'
/usr/local/llvm39/lib/libomp.so: undefined reference to `scalbn'
clang-3.9: error: linker command failed with exit code 1 (use -v to see
invocation)

$ clang40 -fopenmp omp_hello.c
/usr/local/llvm40/lib/libomp.so: undefined reference to `scalbnl'
/usr/local/llvm40/lib/libomp.so: undefined reference to `fmaxl'
/usr/local/llvm40/lib/libomp.so: undefined reference to `logbl'
/usr/local/llvm40/lib/libomp.so: undefined reference to `scalbnf'
/usr/local/llvm40/lib/libomp.so: undefined reference to `logb'
/usr/local/llvm40/lib/libomp.so: undefined reference to `logbf'
/usr/local/llvm40/lib/libomp.so: undefined reference to `scalbn'
clang-4.0: error: linker command failed with exit code 1 (use -v to see
invocation)

$ clang-devel -fopenmp omp_hello.c
/usr/bin/ld: cannot find -lomp
clang-5.0: error: linker command failed with exit code 1 (use -v to see
invocation)

$ clang-devel -fopenmp omp_hello.c $(llvm-config-devel --ldflags)
/usr/local/llvm-devel/lib/libomp.so: undefined reference to `scalbnl'
/usr/local/llvm-devel/lib/libomp.so: undefined reference to `fmaxl'
/usr/local/llvm-devel/lib/libomp.so: undefined reference to `logbl'
/usr/local/llvm-devel/lib/libomp.so: undefined reference to `scalbnf'
/usr/local/llvm-devel/lib/libomp.so: undefined reference to `logb'
/usr/local/llvm-devel/lib/libomp.so: undefined reference to `logbf'
/usr/local/llvm-devel/lib/libomp.so: undefined reference to `scalbn'
clang-5.0: error: linker command failed with exit code 1 (use -v to see
invocation)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
___
freebsd-toolchain@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


[Bug 214258] devel/openmp: spurious libm dependency

2017-03-15 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214258

--- Comment #4 from Jan Beich (mail not working)  ---
Comment on attachment 179304
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=179304
ports/devel/openmp/files/patch-link-libm.patch

The workaround isn't really correct. FreeBSD versions before 11.0 don't really
need -lm.

$ clang40 -fopenmp omp_hello.c
$ ldd a.out
a.out:
libomp.so => /usr/local/llvm40/lib/libomp.so (0x80081f000)
libc.so.7 => /lib/libc.so.7 (0x800aa3000)
libthr.so.3 => /lib/libthr.so.3 (0x800e5)

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.
___
freebsd-toolchain@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


[Bug 214258] devel/openmp: spurious libm dependency

2017-03-15 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214258

Jan Beich (mail not working)  changed:

   What|Removed |Added

   Keywords||regression

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.
___
freebsd-toolchain@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


[Bug 214258] devel/openmp: spurious libm dependency

2017-03-15 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214258

Konstantin Belousov  changed:

   What|Removed |Added

 CC||k...@freebsd.org

--- Comment #5 from Konstantin Belousov  ---
(In reply to Jan Beich (mail not working) from comment #4)
A library cannot 'pick up symbols without referencing them'.  The presence of
the the undefined references means that there are real references in the code.

Note that existence of libm.so as a separate shared object from libc is a minor
optimization.  The libm services are mandated by the C standard, so the
separate library is only a way to slighly reduce working set of the programs
that do not need them.  Linking it in is fine.

If you are so intolerate to the presence of -lm in the dependency list even
when symbols are not referenced, you can use '-Wl,--as-needed -lm
-Wl,--no-as-needed' construct to only record DT_NEEDED fro libm.so when
references actually exist.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
___
freebsd-toolchain@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


[Bug 214258] devel/openmp: spurious libm dependency

2017-03-15 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214258

--- Comment #6 from Jan Beich (mail not working)  ---
(In reply to Konstantin Belousov from comment #5)
> If you are so intolerate to the presence of -lm in the dependency
> list even when symbols are not referenced, you can use
> '-Wl,--as-needed -lm -Wl,--no-as-needed' construct to only record
> DT_NEEDED fro libm.so when references actually exist.

devel/openmp already adds -Wl,--as-needed and it doesn't work because the
references come either from libgcc, crt or something similar.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
___
freebsd-toolchain@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


[Bug 214258] devel/openmp: spurious libm dependency

2017-03-15 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214258

--- Comment #7 from Jan Beich (mail not working)  ---
LDFLAGS+=-Wl,--verbose diff shows:

+(/usr/lib/libgcc.a)mulxc3.o
+(/usr/lib/libgcc.a)mulsc3.o
+(/usr/lib/libgcc.a)muldc3.o
+(/usr/lib/libgcc.a)divxc3.o
+(/usr/lib/libgcc.a)divsc3.o
+(/usr/lib/libgcc.a)divdc3.o

while nm kmp_atomic.cpp.o diff shows:

- U _GLOBAL_OFFSET_TABLE_
+ U __divdc3
+ U __divsc3
+ U __divxc3
+ U __muldc3
+ U __mulsc3
+ U __mulxc3

but using older libgcc.a won't help:

$ nm -A /poudriere/jails/103amd64/usr/lib/libgcc.a | fgrep scalbnl
/poudriere/jails/103amd64/usr/lib/libgcc.a:divxc3.o: U scalbnl

$ nm -A /poudriere/jails/110amd64/usr/lib/libgcc.a | fgrep scalbnl
/poudriere/jails/110amd64/usr/lib/libgcc.a:divxc3.o: U scalbnl
/poudriere/jails/110amd64/usr/lib/libgcc.a:divtc3.o: U scalbnl

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.
___
freebsd-toolchain@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


[Bug 214258] devel/openmp: spurious libm dependency

2017-03-15 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214258

--- Comment #8 from Konstantin Belousov  ---
(In reply to Jan Beich (mail not working) from comment #7)
Which means that libm is really needed.

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.
___
freebsd-toolchain@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


[Bug 214258] devel/openmp: spurious libm dependency

2017-03-15 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214258

--- Comment #9 from Jan Beich (mail not working)  ---
Maybe but cc -E doesn't show any calls to __divdc3 et al.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
___
freebsd-toolchain@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


[Bug 214258] devel/openmp: spurious libm dependency

2017-03-15 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214258

--- Comment #10 from Konstantin Belousov  ---
(In reply to Jan Beich (mail not working) from comment #9)
Why it should ?  The symbols like __divdc3 are referenced by a
compiler-generated code,  for instance the __divdc3 definition is
   complex double __divdc3 (double a, double b, double c, double d)
with the semantic of return ((a + i * b) / (c + i * d)), where i is imaginary
one.  The source code should contain complex division operation, not __divdc3
call, to get the reference.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
___
freebsd-toolchain@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


[Bug 214258] devel/openmp: spurious libm dependency

2017-03-15 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214258

--- Comment #11 from Jan Beich (mail not working)  ---
Because if compiler emits undefined references the linker cannot be expected to
know when -lm is required. Looking at
contrib/llvm/tools/clang/lib/Driver/Tools.cpp there are already cases when -lm
is passed together with --no-as-needed. Maybe something like 
https://reviews.llvm.org/D5698 added one more case.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
___
freebsd-toolchain@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


[Bug 214258] devel/openmp: spurious libm dependency

2017-03-15 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214258

Jan Beich (mail not working)  changed:

   What|Removed |Added

   See Also||https://bugs.llvm.org//show
   ||_bug.cgi?id=32279

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.
___
freebsd-toolchain@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


[Bug 214258] devel/openmp: spurious libm dependency

2017-03-29 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214258

Jan Beich (mail not working)  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|New |Closed
 Blocks||210337
   Assignee|freebsd-toolchain@FreeBSD.o |jbe...@freebsd.org
   |rg  |
  Flags|maintainer-feedback?(bapt@F |
   |reeBSD.org) |

--- Comment #12 from Jan Beich (mail not working)  ---
2017Q2 is around the corner, so I've landed before upstream review. ;\

https://svnweb.freebsd.org/changeset/ports/437204


Referenced Bugs:

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=210337
[Bug 210337] [exp-run] allow libiomp for openmp when using clang on amd64
-- 
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.
___
freebsd-toolchain@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


[Bug 214258] devel/openmp: spurious libm dependency

2017-03-29 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214258

--- Comment #13 from commit-h...@freebsd.org ---
A commit references this bug:

Author: jbeich
Date: Wed Mar 29 14:43:30 UTC 2017
New revision: 437204
URL: https://svnweb.freebsd.org/changeset/ports/437204

Log:
  devel/openmp: link libomp.so against -lm for clang 3.6+

  PR:   214258
  Submitted by: Yuta Satoh 
  Approved by:  portmgr blanket

Changes:
  head/devel/llvm-devel/Makefile
  head/devel/llvm-devel/files/openmp-patch-bug32279
  head/devel/llvm37/Makefile
  head/devel/llvm37/files/openmp-patch-bug32279
  head/devel/llvm38/Makefile
  head/devel/llvm38/files/openmp-patch-bug32279
  head/devel/llvm39/Makefile
  head/devel/llvm39/files/openmp-patch-bug32279
  head/devel/llvm40/Makefile
  head/devel/llvm40/files/openmp-patch-bug32279
  head/devel/openmp/Makefile
  head/devel/openmp/files/patch-bug32279

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
freebsd-toolchain@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"