[Bug 260791] lang/ruby30 (2021Q4) does not compile on Haswell

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 29 Dec 2021 10:35:32 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=260791

            Bug ID: 260791
           Summary: lang/ruby30 (2021Q4) does not compile on Haswell
           Product: Ports & Packages
           Version: Latest
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: Individual Port(s)
          Assignee: ruby@FreeBSD.org
          Reporter: pmc@citylink.dinoex.sub.org
             Flags: maintainer-feedback?(ruby@FreeBSD.org)
          Assignee: ruby@FreeBSD.org

To reproduce:
-------------
set /etc/make.conf:
  CPUTYPE?=haswell

Error:
------
--- numeric.o ---
compiling numeric.c
In file included from numeric.c:35:
In file included from ./internal/numeric.h:13:
./internal/bits.h:240:26: warning: implicit declaration of function
'_lzcnt_u32'
 is invalid in C99 [-Wimplicit-function-declaration]
    return (unsigned int)_lzcnt_u32(x);
                         ^
./internal/bits.h:269:26: warning: implicit declaration of function
'_lzcnt_u64'
 is invalid in C99 [-Wimplicit-function-declaration]
    return (unsigned int)_lzcnt_u64(x);
                         ^
./internal/bits.h:455:22: warning: implicit declaration of function
'_tzcnt_u32' is invalid in C99 [-Wimplicit-function-declaration]
    return (unsigned)_tzcnt_u32(x);
                     ^
./internal/bits.h:477:22: warning: implicit declaration of function
'_tzcnt_u64' is invalid in C99 [-Wimplicit-function-declaration]
    return (unsigned)_tzcnt_u64(x);
                     ^
[...]
ld: error: undefined symbol: _lzcnt_u32
>>> referenced by bignum.c
>>>               bignum.o:(bary_divmod_normal)
>>> referenced by bignum.c
>>>               bignum.o:(rb_absint_size)
>>> referenced by bignum.c
>>>               bignum.o:(rb_absint_numwords)
>>> referenced by bignum.c
>>>               bignum.o:(rb_absint_numwords)
>>> referenced by bignum.c
>>>               bignum.o:(rb_int_parse_cstr)
>>> referenced by bignum.c
>>>               bignum.o:(rb_str2big_poweroftwo)
>>> referenced by bignum.c
>>>               bignum.o:(big2ulong)
>>> referenced by bignum.c
>>>               bignum.o:(big2ulong)
>>> referenced by bignum.c
>>>               bignum.o:(big2ull)
>>> referenced by bignum.c
>>>               bignum.o:(big2ull)
>>> referenced 18 more times

ld: error: undefined symbol: _tzcnt_u32
>>> referenced by compile.c
>>>               compile.o:(ibf_load_iseq_each)
>>> referenced by compile.c
>>>               compile.o:(ibf_load_iseq_each)
>>> referenced by compile.c
>>>               compile.o:(ibf_load_iseq_each)
>>> referenced by compile.c
>>>               compile.o:(ibf_load_iseq_each)
>>> referenced by compile.c
>>>               compile.o:(ibf_load_iseq_each)
>>> referenced by compile.c
>>>               compile.o:(ibf_load_iseq_each)
>>> referenced by compile.c
>>>               compile.o:(ibf_load_iseq_each)
>>> referenced by compile.c
>>>               compile.o:(ibf_load_iseq_each)
>>> referenced by compile.c
>>>               compile.o:(ibf_load_iseq_each)
>>> referenced by compile.c
>>>               compile.o:(ibf_load_iseq_each)
>>> referenced 66 more times

ld: error: undefined symbol: _lzcnt_u64
>>> referenced by numeric.c
>>>               numeric.o:(rb_int_bit_length)
>>> referenced by numeric.c
>>>               numeric.o:(rb_ulong_isqrt)
>>> referenced by numeric.c
>>>               numeric.o:(rb_int_s_isqrt)
>>> referenced by numeric.c
>>>               numeric.o:(builtin_inline_class_75)
>>> referenced by random.c
>>>               random.o:(random_ulong_limited)
>>> referenced by st.c
>>>               st.o:(rb_st_init_table_with_size)

ld: error: undefined symbol: _tzcnt_u64
>>> referenced by string.c
>>>               string.o:(rb_str_coderange_scan_restartable)
>>> referenced by string.c
>>>               string.o:(rb_str_coderange_scan_restartable)
>>> referenced by string.c
>>>               string.o:(rb_str_coderange_scan_restartable)
>>> referenced by string.c
>>>               string.o:(rb_external_str_new_with_enc)
>>> referenced by string.c
>>>               string.o:(rb_external_str_new_with_enc)
>>> referenced by string.c
>>>               string.o:(enc_strlen)
>>> referenced by string.c
>>>               string.o:(enc_strlen)
>>> referenced by string.c
>>>               string.o:(rb_enc_strlen_cr)
>>> referenced by string.c
>>>               string.o:(rb_enc_cr_str_copy_for_substr)
>>> referenced by string.c
>>>               string.o:(str_nth_len)
>>> referenced 5 more times
cc: error: linker command failed with exit code 1 (use -v to see invocation)
*** [miniruby] Error code 1

Analysis:
---------
internal/bits.h fails to include <x86intrin.h> because configure does not find
it.
Configure does not find it because it does search for it only on certain
'x86_64' etc. machine, but we are 'amd64' machine:

configure.ac:
  AS_CASE("$target_cpu", [x64|x86_64|i[3-6]86*], [
    AC_CHECK_HEADERS(x86intrin.h)
  ])

---
configure:3327: checking target system type
configure:3340: result: amd64-portbld-freebsd12

I have no idea which party is wrong here, but adding 'amd64' into configure.ac
solves the matter.

-- 
You are receiving this mail because:
You are the assignee for the bug.