Bug 195881 - audio/opus-tools build fails (missing header for i386)
Summary: audio/opus-tools build fails (missing header for i386)
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Christian Weisgerber
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-11 08:29 UTC by woot-woot
Modified: 2014-12-31 15:47 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (naddy)


Attachments
Fix opus-tools build on 9/i386 with CPUTYPE=pentium-m (1.15 KB, patch)
2014-12-29 18:09 UTC, Christian Weisgerber
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description woot-woot 2014-12-11 08:29:51 UTC
Building for opus-tools-0.1.9_1
/usr/bin/make  all-recursive
Making all in .
  CC       src/opusdec-opus_header.o
CC       src/opusdec-wav_io.o
  CC       src/opusdec-wave_out.o
  CC       src/opusdec-opusdec.o
  CC       src/opusdec-resample.o
CC       src/opusdec-diag_range.o
  CC       src/opusenc-opus_header.o
In file included from src/resample.c:101:
src/resample_sse.h: In function 'inner_product_single':
src/resample_sse.h:47: warning: comparison between signed and unsigned
src/resample_sse.h:59: warning: comparison between signed and unsigned
src/resample_sse.h: In function 'interpolate_product_single':
src/resample_sse.h:72: warning: comparison between signed and unsigned
src/resample_sse.h:85: warning: comparison between signed and unsigned
src/resample_sse.h: In function 'inner_product_double':
src/resample_sse.h:108: warning: comparison between signed and unsigned
src/resample_sse.h: In function 'interpolate_product_double':
src/resample_sse.h:134: warning: comparison between signed and unsigned
src/resample.c: In function 'update_filter':
src/resample.c:607: warning: comparison between signed and unsigned
src/resample.c:688: warning: comparison between signed and unsigned
src/resample.c:696: warning: comparison between signed and unsigned
src/resample.c:699: warning: comparison between signed and unsigned
src/resample.c:706: warning: comparison between signed and unsigned
src/resample.c: In function 'opustools_resampler_process_float':
src/resample.c:872: warning: comparison between signed and unsigned
src/resample.c:875: warning: comparison between signed and unsigned
src/resample.c: In function 'opustools_resampler_process_int':
src/resample.c:928: warning: comparison between signed and unsigned
src/resample.c:935: warning: comparison between signed and unsigned
src/resample.c:945: warning: comparison between signed and unsigned
In file included from src/opusdec.c:101:
src/cpusupport.h:53:19: error: cpuid.h: No such file or directory
In file included from src/opusdec.c:101:
src/cpusupport.h: In function 'query_cpu_support':
src/cpusupport.h:57: warning: implicit declaration of function '__get_cpuid'
src/cpusupport.h:57: warning: nested extern declaration of '__get_cpuid'
src/diag_range.c: In function 'save_range':
src/diag_range.c:77: warning: 'count' may be used uninitialized in this function
src/diag_range.c:77: note: 'count' was declared here
*** [src/opusdec-opusdec.o] Error code 1
1 error
*** [all-recursive] Error code 1
1 error
*** [all] Error code 2
1 error
===> Compilation failed unexpectedly.

No problems for amd64.
Atm i am fixing this by copying cpuid.h from /usr/src.
#cd /usr/ports/audio/opus-tools
#make extract
#cp /usr/src/contrib/llvm/tools/clang/lib/Headers/cpuid.h work/opus-tools-0.1.9/src/
# make install

maybe its can be fixed in proper way?
Comment 1 Bugzilla Automation freebsd_committer 2014-12-11 08:29:51 UTC
Auto-assigned to maintainer naddy@FreeBSD.org
Comment 2 Christian Weisgerber freebsd_committer 2014-12-12 18:17:22 UTC
(In reply to woot-woot from comment #0)

What version of FreeBSD is this? Is this a nonstandard system in some way? A different compiler? CFLAGS?

Portsmon does not show any build failures on i386.
http://portsmon.freebsd.org/portoverview.py?category=audio&portname=opus-tools
Comment 3 woot-woot 2014-12-28 17:32:00 UTC
9.3-STABLE FreeBSD 9.3-STABLE #0 r276292
ports updated today

building whole system with ports from zero, i removed my make.conf completely and run make:

#cd /usr/ports/audio/opus-tools/
#make

===>  Building for opus-tools-0.1.9_1
/usr/bin/make  all-recursive
Making all in .
CC       src/opusenc-opus_header.o
  CC       src/opusinfo-opus_header.o
  CC       src/opusenc-opusenc.o
  CC       src/opusenc-picture.o
In file included from src/opusenc.c:71:
src/cpusupport.h:53:19: error: cpuid.h: No such file or directory
In file included from src/opusenc.c:71:
src/cpusupport.h: In function 'query_cpu_support':
src/cpusupport.h:57: warning: implicit declaration of function '__get_cpuid'
src/cpusupport.h:57: warning: nested extern declaration of '__get_cpuid'
*** [src/opusenc-opusenc.o] Error code 1
1 error
*** [all-recursive] Error code 1
1 error
*** [all] Error code 2
1 error
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** [do-build] Error code 1

Stop in /usr/ports/audio/opus-tools.

No problems for amd64
Comment 4 woot-woot 2014-12-28 17:38:02 UTC
Well i found issue

in last attempt i didn't "make clean".

So port build failed when "CPUTYPE?=pentium-m" directive is present.
Commenting this string in make.conf is helps.
Comment 5 woot-woot 2014-12-28 17:46:21 UTC
or

#cd /usr/ports/audio/opus-tools/
#make extract
#cp /usr/src/contrib/llvm/tools/clang/lib/Headers/cpuid.h work/opus-tools-0.1.9/src
#make install

helps too, if CPUTYPE is defined in make.conf
Comment 6 Christian Weisgerber freebsd_committer 2014-12-29 18:09:39 UTC
Created attachment 151083 [details]
Fix opus-tools build on 9/i386 with CPUTYPE=pentium-m

Setting CPUTYPE=pentium-m will cause __SSE__ to become defined. This triggers an #ifdef branch where <cpuid.h> will be included. However, GCC on FreeBSD 9 does not have the <cpuid.h> header.  (Clang has it.)

As a fix, query_cpu_support() will now skip cpuid and always report 0. This shouldn't have any negative consequences as query_cpu_support() is only used in a sanity check that we don't need.

Please test.
Comment 7 woot-woot 2014-12-30 22:54:44 UTC
Something wrong with patch

i put it in port:
#ll /usr/ports/audio/opus-tools/files
total 4
-rw-r--r--  1 root  wheel  832 31 дек 01:39 patch-src_cpusupport.h

then
#make clean && make

and its show similar to unpatched port error:
===>  Cleaning for opus-tools-0.1.9_1
===>   opus-tools-0.1.9_1 depends on file: /usr/local/sbin/pkg - found
===> Fetching all distfiles required by opus-tools-0.1.9_1 for building
===>  Extracting for opus-tools-0.1.9_1
=> SHA256 Checksum OK for opus-tools-0.1.9.tar.gz.
===>  Patching for opus-tools-0.1.9_1
===>  Applying FreeBSD patches for opus-tools-0.1.9_1
===>   opus-tools-0.1.9_1 depends on executable: pkgconf - found
===>   opus-tools-0.1.9_1 depends on shared library: libFLAC.so - found (/usr/local/lib/libFLAC.so.8.3.0)
===>   opus-tools-0.1.9_1 depends on shared library: libogg.so - found (/usr/local/lib/libogg.so.0.8.2)
===>   opus-tools-0.1.9_1 depends on shared library: libopus.so - found (/usr/local/lib/libopus.so.0.5.0)
===>  Configuring for opus-tools-0.1.9_1
configure: loading site script /usr/ports/Templates/config.site
checking whether make supports nested variables... yes
checking for a BSD-compatible install... /usr/bin/install -c -o root -g wheel
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... (cached) /bin/mkdir -p
checking for gawk... (cached) /usr/bin/awk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking build system type... i386-portbld-freebsd9.3
checking host system type... i386-portbld-freebsd9.3
checking for style of include used by make... GNU
checking for gcc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking dependency style of cc... gcc3
checking whether cc understands -c and -o together... yes
checking for cc option to accept ISO C99... -std=gnu99
checking how to run the C preprocessor... cpp
checking for grep that handles long lines and -e... (cached) /usr/bin/grep
checking for egrep... (cached) /usr/bin/egrep
checking for ANSI C header files... (cached) yes
checking for sys/types.h... (cached) yes
checking for sys/stat.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for memory.h... (cached) yes
checking for strings.h... (cached) yes
checking for inttypes.h... (cached) yes
checking for stdint.h... (cached) yes
checking for unistd.h... (cached) yes
checking whether byte ordering is bigendian... no
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for C/C++ restrict keyword... __restrict
checking for C99 variable-size arrays... yes
checking for cos in -lm... yes
checking for main in -lwinmm... no
checking for pkg-config... yes
checking pkg-config is at least version 0.9.0... yes
checking for OGG... yes
checking for OPUS... yes
checking sys/soundcard.h usability... yes
checking sys/soundcard.h presence... yes
checking for sys/soundcard.h... yes
checking for sio_open in -lsndio... no
checking for FLAC... yes
checking for pcap_open_live in -lpcap... yes
checking if cc -std=gnu99 supports -fstack-protector-all... yes
checking for PIE support... no
checking if cc -std=gnu99 supports -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes... yes
checking for _LARGEFILE_SOURCE value needed for large files... no
checking for lrintf... yes
checking for fminf... yes
checking for fmaxf... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands
configure:
------------------------------------------------------------------------
  opus-tools 0.1.9:  Automatic configuration OK.

    Compiler support:

      C99 var arrays: ................ yes
      C99 lrintf: .................... yes
      Stack protector: ............... yes
      PIE: ........................... no

    General configuration:

      Assertion checking: ............ no
      FLAC input: .................... yes

------------------------------------------------------------------------

 Type "make; make install" to compile and install

===>  Building for opus-tools-0.1.9_1
/usr/bin/make  all-recursive
Making all in .
  CC       src/opusenc-opus_header.o
  CC       src/opusenc-opusenc.o
In file included from src/opusenc.c:71:
src/cpusupport.h:53:19: error: cpuid.h: No such file or directory
In file included from src/opusenc.c:71:
src/cpusupport.h: In function 'query_cpu_support':
src/cpusupport.h:57: warning: implicit declaration of function '__get_cpuid'
src/cpusupport.h:57: warning: nested extern declaration of '__get_cpuid'
*** [src/opusenc-opusenc.o] Error code 1

Stop in /usr/ports/audio/opus-tools/work/opus-tools-0.1.9.
*** [all-recursive] Error code 1

Stop in /usr/ports/audio/opus-tools/work/opus-tools-0.1.9.
*** [all] Error code 1

Stop in /usr/ports/audio/opus-tools/work/opus-tools-0.1.9.
*** [do-build] Error code 1

Stop in /usr/ports/audio/opus-tools.

patch didn't applied to src/cpusupport.h for some reason.

sadly i am not good at patch tool to understand what is wrong, but when i changed original string
"if !defined(__SSE__) || defined(_M_X64) || defined(__amd64__)"

to patched one "++/* XXX  GCC on FreeBSD 9 does not have <cpuid.h>.  On i386, __SSE__ can
++   appear with -march=CPU-TYPE, so disable the SSE check completely. */
++# if !defined(__SSE__) || defined(_M_X64) || defined(__amd64__) || defined(__i386__)"

its successfully compiled.

So probably there a proper version of patch:
#diff -Naur cpusupport.h.orig cpusupport.h

--- cpusupport.h.orig   2012-12-18 03:17:07.000000000 +0400
+++ cpusupport.h        2014-12-31 01:51:07.000000000 +0300
@@ -33,7 +33,9 @@
    on a host without those instructions. Therefore we disable
    the query both if the compiler isn't supporting SSE, and on
    targets which are guaranteed to have SSE. */
-# if !defined(__SSE__) || defined(_M_X64) || defined(__amd64__)
+/* XXX  GCC on FreeBSD 9 does not have <cpuid.h>.  On i386, __SSE__ can
+   appear with -march=CPU-TYPE, so disable the SSE check completely. */
+# if !defined(__SSE__) || defined(_M_X64) || defined(__amd64__) || defined(__i386__)
 #  define query_cpu_support() 0
 # else
Comment 8 commit-hook freebsd_committer 2014-12-31 15:46:22 UTC
A commit references this bug:

Author: naddy
Date: Wed Dec 31 15:46:12 UTC 2014
New revision: 375895
URL: https://svnweb.freebsd.org/changeset/ports/375895

Log:
  On i386, setting CPUTYPE=pentium-m or such will cause __SSE__ to
  appear.  This in turn triggers an #ifdef branch that tries to include
  <cpuid.h>, but gcc on 9.x doesn't have that header.  Make
  query_cpu_support() skip cpuid and always return 0 as it is only
  used for a sanity check that we don't need.

  PR:		195881

Changes:
  head/audio/opus-tools/files/
  head/audio/opus-tools/files/patch-src_cpusupport.h