Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gem install nokogiri-xmlsec-instructure failing #15

Closed
Loschcode opened this issue Oct 19, 2022 · 31 comments
Closed

Gem install nokogiri-xmlsec-instructure failing #15

Loschcode opened this issue Oct 19, 2022 · 31 comments

Comments

@Loschcode
Copy link

On ARM64, I can't find a way to make it work. I've looked everywhere and tried to find workarounds such as reinstalling XCode, reinstalling entirely Ruby, reinstalling a bunch of libraries with brew

gem install nokogiri-xmlsec-instructure
Building native extensions. This could take a while...
ERROR:  Error installing nokogiri-xmlsec-instructure:
	ERROR: Failed to build gem native extension.

    current directory: /Users/loschcode/.rvm/gems/ruby-3.1.0/gems/nokogiri-xmlsec-instructure-0.10.1/ext/nokogiri_ext_xmlsec
/Users/loschcode/.rvm/rubies/ruby-3.1.0/bin/ruby -I /Users/loschcode/.rvm/rubies/ruby-3.1.0/lib/ruby/site_ruby/3.1.0 extconf.rb
checking for ruby.h... yes
Clfags: -O3 -I/opt/homebrew/opt/libyaml/include -I/opt/homebrew/opt/libksba/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/zlib/include -I/opt/homebrew/opt/openssl@1.1/include $(cflags) -fno-common -pipe -D__XMLSEC_FUNCTION__=__func__ -DXMLSEC_NO_SIZE_T -DXMLSEC_NO_GOST=1 -DXMLSEC_NO_GOST2012=1 -DXMLSEC_NO_CRYPTO_DYNAMIC_LOADING=1 -DXMLSEC_CRYPTO_OPENSSL=1 -D__XMLSEC_FUNCTION__=__func__ -DXMLSEC_NO_SIZE_T -DXMLSEC_NO_GOST=1 -DXMLSEC_NO_GOST2012=1 -DXMLSEC_NO_CRYPTO_DYNAMIC_LOADING=1 -I/opt/homebrew/Cellar/libxmlsec1/1.2.34_1/include/xmlsec1 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -I/opt/homebrew/opt/openssl@1.1/include -I/opt/homebrew/opt/openssl@1.1/include/openssl -DXMLSEC_CRYPTO_OPENSSL=1 -fvisibility=hidden
creating Makefile

current directory: /Users/loschcode/.rvm/gems/ruby-3.1.0/gems/nokogiri-xmlsec-instructure-0.10.1/ext/nokogiri_ext_xmlsec
make DESTDIR\= sitearchdir\=./.gem.20221019-14968-ujwwzw sitelibdir\=./.gem.20221019-14968-ujwwzw clean

current directory: /Users/loschcode/.rvm/gems/ruby-3.1.0/gems/nokogiri-xmlsec-instructure-0.10.1/ext/nokogiri_ext_xmlsec
make DESTDIR\= sitearchdir\=./.gem.20221019-14968-ujwwzw sitelibdir\=./.gem.20221019-14968-ujwwzw
compiling init.c
compiling nokogiri_decrypt_with_key.c
nokogiri_decrypt_with_key.c:26:15: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
  keyLength = RSTRING_LEN(rb_key);
            ~ ^~~~~~~~~~~~~~~~~~~
/Users/loschcode/.rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
1 warning generated.
compiling nokogiri_encrypt_with_key.c
nokogiri_encrypt_with_key.c:37:15: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
  keyLength = RSTRING_LEN(rb_rsa_key);
            ~ ^~~~~~~~~~~~~~~~~~~~~~~
/Users/loschcode/.rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
nokogiri_encrypt_with_key.c:47:25: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
    certificateLength = RSTRING_LEN(rb_cert);
                      ~ ^~~~~~~~~~~~~~~~~~~~
/Users/loschcode/.rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
2 warnings generated.
compiling nokogiri_helpers_set_attribute_id.c
compiling nokogiri_init.c
compiling nokogiri_sign.c
nokogiri_sign.c:59:18: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
  rsaKeyLength = RSTRING_LEN(rb_rsa_key);
               ~ ^~~~~~~~~~~~~~~~~~~~~~~
/Users/loschcode/.rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
nokogiri_sign.c:64:25: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
    certificateLength = RSTRING_LEN(rb_cert);
                      ~ ^~~~~~~~~~~~~~~~~~~~
/Users/loschcode/.rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
2 warnings generated.
compiling nokogiri_verify_with.c
nokogiri_verify_with.c:14:18: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  int numCerts = RARRAY_LEN(rb_certs);
      ~~~~~~~~   ^~~~~~~~~~~~~~~~~~~~
/Users/loschcode/.rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/core/rarray.h:68:36: note: expanded from macro 'RARRAY_LEN'
#define RARRAY_LEN                 rb_array_len                 /**< @alias{rb_array_len} */
                                   ^
nokogiri_verify_with.c:38:18: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
    certLength = RSTRING_LEN(rb_cert);
               ~ ^~~~~~~~~~~~~~~~~~~~
/Users/loschcode/.rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
nokogiri_verify_with.c:81:19: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
  keyDataLength = RSTRING_LEN(rb_value);
                ~ ^~~~~~~~~~~~~~~~~~~~~
/Users/loschcode/.rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
nokogiri_verify_with.c:183:22: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
    rsa_key_length = RSTRING_LEN(rb_rsa_key);
                   ~ ^~~~~~~~~~~~~~~~~~~~~~~
/Users/loschcode/.rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
nokogiri_verify_with.c:212:54: warning: implicit conversion loses integer precision: 'time_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
    dsigCtx->keyInfoReadCtx.certsVerificationDepth = (time_t)NUM2LONG(rb_verification_depth);
                                                   ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 warnings generated.
compiling options.c
options.c:65:28: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  int blockEncryptionLen = RSTRING_LEN(rb_block_encryption);
      ~~~~~~~~~~~~~~~~~~   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/loschcode/.rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
options.c:67:25: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  int keyTransportLen = RSTRING_LEN(rb_key_transport);
      ~~~~~~~~~~~~~~~   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/loschcode/.rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
options.c:108:43: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
  unsigned int signatureAlgorithmLength = RSTRING_LEN(rb_signature_alg);
               ~~~~~~~~~~~~~~~~~~~~~~~~   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/loschcode/.rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
options.c:149:40: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
  unsigned int digestAlgorithmLength = RSTRING_LEN(rb_digest_alg);
               ~~~~~~~~~~~~~~~~~~~~~   ^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/loschcode/.rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
4 warnings generated.
compiling shutdown.c
compiling util.c
linking shared-object nokogiri_ext_xmlsec.bundle
Undefined symbols for architecture arm64:
  "_noko_xml_document_pin_node", referenced from:
      _decrypt_with_key in nokogiri_decrypt_with_key.o
  "_noko_xml_node_wrap", referenced from:
      _get_id in nokogiri_helpers_set_attribute_id.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [nokogiri_ext_xmlsec.bundle] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/loschcode/.rvm/gems/ruby-3.1.0/gems/nokogiri-xmlsec-instructure-0.10.1 for inspection.
Results logged to /Users/loschcode/.rvm/gems/ruby-3.1.0/extensions/arm64-darwin-21/3.1.0/nokogiri-xmlsec-instructure-0.10.1/gem_make.out

Any idea what's going on here?

@flavorjones
Copy link

Can you help me reproduce this? I'm on an ARM64 Mac, running Ruby 3.1.2, and I have Nokogiri v1.13.8 installed:

$ gem install nokogiri-xmlsec-instructure
Building native extensions. This could take a while...
Successfully installed nokogiri-xmlsec-instructure-0.10.1
1 gem installed

@flavorjones
Copy link

Here's my nokogiri installation:

$ nokogiri -v
# Nokogiri (1.13.8)
    ---
    warnings: []
    nokogiri:
      version: 1.13.8
      cppflags:
      - "-I/Users/flavorjones/.gem/ruby/3.1.2/gems/nokogiri-1.13.8-arm64-darwin/ext/nokogiri"
      - "-I/Users/flavorjones/.gem/ruby/3.1.2/gems/nokogiri-1.13.8-arm64-darwin/ext/nokogiri/include"
      - "-I/Users/flavorjones/.gem/ruby/3.1.2/gems/nokogiri-1.13.8-arm64-darwin/ext/nokogiri/include/libxml2"
      ldflags: []
    ruby:
      version: 3.1.2
      platform: arm64-darwin21
      gem_platform: arm64-darwin-21
      description: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]
      engine: ruby
    libxml:
      source: packaged
      precompiled: true
      patches:
      - 0001-Remove-script-macro-support.patch
      - 0002-Update-entities-to-remove-handling-of-ssi.patch
      - 0003-libxml2.la-is-in-top_builddir.patch
      - 0004-use-glibc-strlen.patch
      - 0005-avoid-isnan-isinf.patch
      - 0006-update-automake-files-for-arm64.patch
      - '0008-htmlParseComment-handle-abruptly-closed-comments.patch'
      - '0009-allow-wildcard-namespaces.patch'
      libxml2_path: "/Users/flavorjones/.gem/ruby/3.1.2/gems/nokogiri-1.13.8-arm64-darwin/ext/nokogiri"
      memory_management: ruby
      iconv_enabled: true
      compiled: 2.9.14
      loaded: 2.9.14
    libxslt:
      source: packaged
      precompiled: true
      patches:
      - 0001-update-automake-files-for-arm64.patch
      datetime_enabled: true
      compiled: 1.1.35
      loaded: 1.1.35
    other_libraries:
      zlib: 1.2.12
      libiconv: '1.16'
      libgumbo: 1.0.0-nokogiri

@flavorjones
Copy link

It looks like the undefined symbols that this gem is looking for are in Nokogiri v1.11.2 and later. You're probably on an older version?

@Loschcode
Copy link
Author

Loschcode commented Oct 20, 2022

Hi, thanks for the quick response, this is where I'm at:

➜  gem list | grep nokogiri
nokogiri (1.13.9 arm64-darwin)
➜  ruby -v
ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [arm64-darwin21]

It crashes the exact same way as I first wrote, so would it mean it's not compatible with the Nokogiri I have right now?

@flavorjones
Copy link

@Loschcode Help me reproduce what you're seeing? I am on arm64-darwin and cannot reproduce this. Can you please reply with the output from nokogiri -v?

@Loschcode
Copy link
Author

Sorry for that, here's the output

➜  nokogiri -v
# Nokogiri (1.13.8)
    ---
    warnings: []
    nokogiri:
      version: 1.13.8
      cppflags:
      - "-I/Users/loschcode/.rvm/gems/ruby-3.1.2/gems/nokogiri-1.13.8/ext/nokogiri"
      - "-I/Users/loschcode/.rvm/gems/ruby-3.1.2/gems/nokogiri-1.13.8/ext/nokogiri/include"
      - "-I/Users/loschcode/.rvm/gems/ruby-3.1.2/gems/nokogiri-1.13.8/ext/nokogiri/include/libxml2"
      ldflags: []
    ruby:
      version: 3.1.2
      platform: arm64-darwin21
      gem_platform: arm64-darwin-21
      description: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]
      engine: ruby
    libxml:
      source: packaged
      precompiled: false
      patches:
      - 0001-Remove-script-macro-support.patch
      - 0002-Update-entities-to-remove-handling-of-ssi.patch
      - 0003-libxml2.la-is-in-top_builddir.patch
      - 0004-use-glibc-strlen.patch
      - 0005-avoid-isnan-isinf.patch
      - 0006-update-automake-files-for-arm64.patch
      - '0008-htmlParseComment-handle-abruptly-closed-comments.patch'
      - '0009-allow-wildcard-namespaces.patch'
      libxml2_path: "/Users/loschcode/.rvm/gems/ruby-3.1.2/gems/nokogiri-1.13.8/ext/nokogiri"
      memory_management: ruby
      iconv_enabled: true
      compiled: 2.9.14
      loaded: 2.9.14
    libxslt:
      source: packaged
      precompiled: false
      patches:
      - 0001-update-automake-files-for-arm64.patch
      datetime_enabled: true
      compiled: 1.1.35
      loaded: 1.1.35
    other_libraries:
      libgumbo: 1.0.0-nokogiri

@flavorjones
Copy link

Ah, interesting -- I'm using the precompiled nokogiri gem and you're not. I bet that's the reason we're seeing different things.

Can you try reinstalling nokogiri but ensure you get the native gem? Run gem uninstall nokogiri first (and uninstall all versions) ... then you should see something like

$ gem install nokogiri
Successfully installed nokogiri-1.13.9-arm64-darwin
1 gem installed

(note the -arm64-darwin suffix).

Then try installing nokogiri-xmlsec-instructure again?

@flavorjones
Copy link

(Though I will note that I tried to reproduce by installing Nokogiri from source (not precompiled) and building this gem against it ... and still could not reproduce what you're seeing.)

@Loschcode
Copy link
Author

Oh yes there's a difference, but you should know it's because I've tried a bunch of things and I did try multiple Nokogiri versions, sadly the result is the same with the arm64-darwin one, here's is my nokogiri -v

# Nokogiri (1.13.9)
    ---
    warnings: []
    nokogiri:
      version: 1.13.9
      cppflags:
      - "-I/Users/loschcode/.rvm/gems/ruby-3.1.2/gems/nokogiri-1.13.9-arm64-darwin/ext/nokogiri"
      - "-I/Users/loschcode/.rvm/gems/ruby-3.1.2/gems/nokogiri-1.13.9-arm64-darwin/ext/nokogiri/include"
      - "-I/Users/loschcode/.rvm/gems/ruby-3.1.2/gems/nokogiri-1.13.9-arm64-darwin/ext/nokogiri/include/libxml2"
      ldflags: []
    ruby:
      version: 3.1.2
      platform: arm64-darwin21
      gem_platform: arm64-darwin-21
      description: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]
      engine: ruby
    libxml:
      source: packaged
      precompiled: true
      patches:
      - 0001-Remove-script-macro-support.patch
      - 0002-Update-entities-to-remove-handling-of-ssi.patch
      - 0003-libxml2.la-is-in-top_builddir.patch
      - 0005-avoid-isnan-isinf.patch
      - '0009-allow-wildcard-namespaces.patch'
      libxml2_path: "/Users/loschcode/.rvm/gems/ruby-3.1.2/gems/nokogiri-1.13.9-arm64-darwin/ext/nokogiri"
      memory_management: ruby
      iconv_enabled: true
      compiled: 2.10.3
      loaded: 2.10.3
    libxslt:
      source: packaged
      precompiled: true
      patches:
      - 0001-update-automake-files-for-arm64.patch
      datetime_enabled: true
      compiled: 1.1.37
      loaded: 1.1.37
    other_libraries:
      zlib: 1.2.13
      libiconv: '1.16'
      libgumbo: 1.0.0-nokogiri

It still crashes for me when trying to install nokogiri-xmlsec-instructure

@Loschcode
Copy link
Author

I've also tried to install Nokogiri 1.13.8 instead of 1.13.9 and the result is the same 😢

@Loschcode
Copy link
Author

I've reinstalled a bunch of libraries with brew, reinstalled completely Ruby and see the same error, I also noticed someone had this problem a few days ago but had no answer on Google Groups.

I really can't find a solution for this 😢 I'll keep investigating

@flavorjones
Copy link

flavorjones commented Oct 20, 2022

Let's approach this from the other end ... let's look at the symbols in the nokogiri shared object.

If you run gem list -d nokogiri you should see a single version of Nokogiri installed (if you see multiple, let's talk about that). It will list a directory, something like

Installed at: /Users/flavorjones/.gem/ruby/3.1.2

Find the gem under that directory, for me it's

/Users/flavorjones/.gem/ruby/3.1.2/gems/nokogiri-1.13.9-arm64-darwin/

Find the shared object for Ruby 3.1 under that directory, for me it's

/Users/flavorjones/.gem/ruby/3.1.2/gems/nokogiri-1.13.9-arm64-darwin/lib/nokogiri/3.1/nokogiri.bundle

Run the nm utility on that file, and grep for the missing symbols. For me I see:

$ nm /Users/flavorjones/.gem/ruby/3.1.2/gems/nokogiri-1.13.9-arm64-darwin/lib/nokogiri/3.1/nokogiri.bundle  | fgrep _noko_xml_document_pin_node
0000000000005364 T _noko_xml_document_pin_node
$ nm /Users/flavorjones/.gem/ruby/3.1.2/gems/nokogiri-1.13.9-arm64-darwin/lib/nokogiri/3.1/nokogiri.bundle  | fgrep _noko_xml_node_wrap
0000000000007e50 T _noko_xml_node_wrap
000000000000a644 T _noko_xml_node_wrap_node_set_result

The T indicates the symbol exists and is exported, which is why I'm able to install nokogiri-xmlsec-instructure successfully. What do you see?

@Loschcode
Copy link
Author

Ok so I followed your steps, there's only one version installed

Installed at: /Users/loschcode/.rvm/gems/ruby-3.1.2

The gem under that directory is

/Users/loschcode/.rvm/gems/ruby-3.1.2/gems/nokogiri-1.13.9-arm64-darwin/

There are shared objects in there, for Ruby 2.6, 2.7, 3.0 and 3.1

/Users/loschcode/.rvm/gems/ruby-3.1.2/gems/nokogiri-1.13.9-arm64-darwin/lib/nokogiri/3.1/nokogiri.bundle

This is matching so far. Then I use your command nm

nm /Users/loschcode/.rvm/gems/ruby-3.1.2/gems/nokogiri-1.13.9-arm64-darwin/lib/nokogiri/3.1/nokogiri.bundle |
fgrep _noko_xml_document_pin_node
0000000000005364 T _noko_xml_document_pin_node

Then the other command

nm /Users/loschcode/.rvm/gems/ruby-3.1.2/gems/nokogiri-1.13.9-arm64-darwin/lib/nokogiri/3.1/nokogiri.bundle | fgrep _noko_xml_node_wrap
0000000000007e50 T _noko_xml_node_wrap
000000000000a644 T _noko_xml_node_wrap_node_set_result

Seems like everything is in place 😢 thanks for your time by the way, it's really nice to see your quick responses 👍

@flavorjones
Copy link

That's really strange. Can you double-check for me what the errors are during build against 1.13.9? The original post listed:

Undefined symbols for architecture arm64:
  "_noko_xml_document_pin_node", referenced from:
      _decrypt_with_key in nokogiri_decrypt_with_key.o
  "_noko_xml_node_wrap", referenced from:
      _get_id in nokogiri_helpers_set_attribute_id.o
ld: symbol(s) not found for architecture arm64

but I can't make sense of that unless that log is from a build against a much older version (as mentioned earlier).

@Loschcode
Copy link
Author

It outputs exactly this, so the same

4 warnings generated.
compiling shutdown.c
compiling util.c
linking shared-object nokogiri_ext_xmlsec.bundle
Undefined symbols for architecture arm64:
  "_noko_xml_document_pin_node", referenced from:
      _decrypt_with_key in nokogiri_decrypt_with_key.o
  "_noko_xml_node_wrap", referenced from:
      _get_id in nokogiri_helpers_set_attribute_id.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [nokogiri_ext_xmlsec.bundle] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/loschcode/.rvm/gems/ruby-3.1.2/gems/nokogiri-xmlsec-instructure-0.10.1 for inspection.
Results logged to /Users/loschcode/.rvm/gems/ruby-3.1.2/extensions/arm64-darwin-21/3.1.0/nokogiri-xmlsec-instructure-0.10.1/gem_make.out

I'm really confused as well, everything is as I showed

@flavorjones
Copy link

🤔

Can you reply with the contents of the mkmf.log and the Makefile generated during installation?

@Loschcode
Copy link
Author

Regarding the mkmf.log

have_header: checking for ruby.h... -------------------- yes

DYLD_FALLBACK_LIBRARY_PATH=.:/Users/loschcode/.rvm/rubies/ruby-3.1.2/lib "gcc -o conftest -I/Users/loschcode/.rvm/rubies/ruby-3.1.2/include/ruby-3.1.0/arm64-darwin21 -I/Users/loschcode/.rvm/rubies/ruby-3.1.2/include/ruby-3.1.0/ruby/backward -I/Users/loschcode/.rvm/rubies/ruby-3.1.2/include/ruby-3.1.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -I/opt/homebrew/opt/libyaml/include -I/opt/homebrew/opt/libksba/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/zlib/include -I/opt/homebrew/opt/openssl@1.1/include -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -fno-common -pipe conftest.c  -L. -L/Users/loschcode/.rvm/rubies/ruby-3.1.2/lib -L. -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/libksba/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/zlib/lib -L/opt/homebrew/opt/openssl@1.1/lib -fstack-protector-strong -L/usr/local/lib     -lruby.3.1   "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return !!argv[argc];
6: }
/* end */

DYLD_FALLBACK_LIBRARY_PATH=.:/Users/loschcode/.rvm/rubies/ruby-3.1.2/lib "gcc -I/Users/loschcode/.rvm/rubies/ruby-3.1.2/include/ruby-3.1.0/arm64-darwin21 -I/Users/loschcode/.rvm/rubies/ruby-3.1.2/include/ruby-3.1.0/ruby/backward -I/Users/loschcode/.rvm/rubies/ruby-3.1.2/include/ruby-3.1.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -I/opt/homebrew/opt/libyaml/include -I/opt/homebrew/opt/libksba/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/zlib/include -I/opt/homebrew/opt/openssl@1.1/include -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -fno-common -pipe   -c conftest.c"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <ruby.h>
/* end */

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

DYLD_FALLBACK_LIBRARY_PATH=.:/Users/loschcode/.rvm/rubies/ruby-3.1.2/lib pkg-config --exists xmlsec1
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/loschcode/.rvm/rubies/ruby-3.1.2/lib pkg-config --libs xmlsec1 |
=> "-L/opt/homebrew/Cellar/libxmlsec1/1.2.34_1/lib -L/opt/homebrew/opt/openssl@1.1/lib -lxmlsec1-openssl -lxmlsec1 -lcrypto -lxslt -lxml2 -lz -lpthread -licucore -lm -lxml2\n"
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/loschcode/.rvm/rubies/ruby-3.1.2/lib "gcc -o conftest -I/Users/loschcode/.rvm/rubies/ruby-3.1.2/include/ruby-3.1.0/arm64-darwin21 -I/Users/loschcode/.rvm/rubies/ruby-3.1.2/include/ruby-3.1.0/ruby/backward -I/Users/loschcode/.rvm/rubies/ruby-3.1.2/include/ruby-3.1.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -I/opt/homebrew/opt/libyaml/include -I/opt/homebrew/opt/libksba/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/zlib/include -I/opt/homebrew/opt/openssl@1.1/include -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -fno-common -pipe conftest.c  -L. -L/Users/loschcode/.rvm/rubies/ruby-3.1.2/lib -L. -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/libksba/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/zlib/lib -L/opt/homebrew/opt/openssl@1.1/lib -fstack-protector-strong -L/usr/local/lib     -lruby.3.1 -L/opt/homebrew/Cellar/libxmlsec1/1.2.34_1/lib -L/opt/homebrew/opt/openssl@1.1/lib -lxmlsec1-openssl -lxmlsec1 -lcrypto -lxslt -lxml2 -lz -lpthread -licucore -lm -lxml2  "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return !!argv[argc];
6: }
/* end */

DYLD_FALLBACK_LIBRARY_PATH=.:/Users/loschcode/.rvm/rubies/ruby-3.1.2/lib pkg-config --cflags-only-I xmlsec1 |
=> "-I/opt/homebrew/Cellar/libxmlsec1/1.2.34_1/include/xmlsec1 -I/opt/homebrew/opt/openssl@1.1/include -I/opt/homebrew/opt/openssl@1.1/include/openssl\n"
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/loschcode/.rvm/rubies/ruby-3.1.2/lib pkg-config --cflags-only-other xmlsec1 |
=> "-D__XMLSEC_FUNCTION__=__func__ -DXMLSEC_NO_SIZE_T -DXMLSEC_NO_GOST=1 -DXMLSEC_NO_GOST2012=1 -DXMLSEC_NO_CRYPTO_DYNAMIC_LOADING=1 -DXMLSEC_CRYPTO_OPENSSL=1\n"
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/loschcode/.rvm/rubies/ruby-3.1.2/lib pkg-config --libs-only-l xmlsec1 |
=> "-lxmlsec1-openssl -lxmlsec1 -lcrypto -lxslt -lxml2 -lz -lpthread -licucore -lm -lxml2\n"
package configuration for xmlsec1
incflags: -I/opt/homebrew/Cellar/libxmlsec1/1.2.34_1/include/xmlsec1 -I/opt/homebrew/opt/openssl@1.1/include -I/opt/homebrew/opt/openssl@1.1/include/openssl
cflags: -D__XMLSEC_FUNCTION__=__func__ -DXMLSEC_NO_SIZE_T -DXMLSEC_NO_GOST=1 -DXMLSEC_NO_GOST2012=1 -DXMLSEC_NO_CRYPTO_DYNAMIC_LOADING=1 -DXMLSEC_CRYPTO_OPENSSL=1
ldflags: -L/opt/homebrew/Cellar/libxmlsec1/1.2.34_1/lib -L/opt/homebrew/opt/openssl@1.1/lib
libs: -lxmlsec1-openssl -lxmlsec1 -lcrypto -lxslt -lxml2 -lz -lpthread -licucore -lm -lxml2

And the gem_make.out

current directory: /Users/loschcode/.rvm/gems/ruby-3.1.2/gems/nokogiri-xmlsec-instructure-0.10.1/ext/nokogiri_ext_xmlsec
/Users/loschcode/.rvm/rubies/ruby-3.1.2/bin/ruby -I /Users/loschcode/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0 -r ./siteconf20221021-83417-hl4cyw.rb extconf.rb
checking for ruby.h... yes
Clfags: -O3 -I/opt/homebrew/opt/libyaml/include -I/opt/homebrew/opt/libksba/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/zlib/include -I/opt/homebrew/opt/openssl@1.1/include $(cflags) -fno-common -pipe -D__XMLSEC_FUNCTION__=__func__ -DXMLSEC_NO_SIZE_T -DXMLSEC_NO_GOST=1 -DXMLSEC_NO_GOST2012=1 -DXMLSEC_NO_CRYPTO_DYNAMIC_LOADING=1 -DXMLSEC_CRYPTO_OPENSSL=1 -D__XMLSEC_FUNCTION__=__func__ -DXMLSEC_NO_SIZE_T -DXMLSEC_NO_GOST=1 -DXMLSEC_NO_GOST2012=1 -DXMLSEC_NO_CRYPTO_DYNAMIC_LOADING=1 -I/opt/homebrew/Cellar/libxmlsec1/1.2.34_1/include/xmlsec1 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -I/opt/homebrew/opt/openssl@1.1/include -I/opt/homebrew/opt/openssl@1.1/include/openssl -DXMLSEC_CRYPTO_OPENSSL=1 -fvisibility=hidden
creating Makefile

current directory: /Users/loschcode/.rvm/gems/ruby-3.1.2/gems/nokogiri-xmlsec-instructure-0.10.1/ext/nokogiri_ext_xmlsec
make DESTDIR\= clean

current directory: /Users/loschcode/.rvm/gems/ruby-3.1.2/gems/nokogiri-xmlsec-instructure-0.10.1/ext/nokogiri_ext_xmlsec
make DESTDIR\=
compiling init.c
compiling nokogiri_decrypt_with_key.c
nokogiri_decrypt_with_key.c:26:15: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
  keyLength = RSTRING_LEN(rb_key);
            ~ ^~~~~~~~~~~~~~~~~~~
/Users/loschcode/.rvm/rubies/ruby-3.1.2/include/ruby-3.1.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
1 warning generated.
compiling nokogiri_encrypt_with_key.c
nokogiri_encrypt_with_key.c:37:15: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
  keyLength = RSTRING_LEN(rb_rsa_key);
            ~ ^~~~~~~~~~~~~~~~~~~~~~~
/Users/loschcode/.rvm/rubies/ruby-3.1.2/include/ruby-3.1.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
nokogiri_encrypt_with_key.c:47:25: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
    certificateLength = RSTRING_LEN(rb_cert);
                      ~ ^~~~~~~~~~~~~~~~~~~~
/Users/loschcode/.rvm/rubies/ruby-3.1.2/include/ruby-3.1.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
2 warnings generated.
compiling nokogiri_helpers_set_attribute_id.c
compiling nokogiri_init.c
compiling nokogiri_sign.c
nokogiri_sign.c:59:18: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
  rsaKeyLength = RSTRING_LEN(rb_rsa_key);
               ~ ^~~~~~~~~~~~~~~~~~~~~~~
/Users/loschcode/.rvm/rubies/ruby-3.1.2/include/ruby-3.1.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
nokogiri_sign.c:64:25: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
    certificateLength = RSTRING_LEN(rb_cert);
                      ~ ^~~~~~~~~~~~~~~~~~~~
/Users/loschcode/.rvm/rubies/ruby-3.1.2/include/ruby-3.1.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
2 warnings generated.
compiling nokogiri_verify_with.c
nokogiri_verify_with.c:14:18: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  int numCerts = RARRAY_LEN(rb_certs);
      ~~~~~~~~   ^~~~~~~~~~~~~~~~~~~~
/Users/loschcode/.rvm/rubies/ruby-3.1.2/include/ruby-3.1.0/ruby/internal/core/rarray.h:68:36: note: expanded from macro 'RARRAY_LEN'
#define RARRAY_LEN                 rb_array_len                 /**< @alias{rb_array_len} */
                                   ^
nokogiri_verify_with.c:38:18: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
    certLength = RSTRING_LEN(rb_cert);
               ~ ^~~~~~~~~~~~~~~~~~~~
/Users/loschcode/.rvm/rubies/ruby-3.1.2/include/ruby-3.1.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
nokogiri_verify_with.c:81:19: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
  keyDataLength = RSTRING_LEN(rb_value);
                ~ ^~~~~~~~~~~~~~~~~~~~~
/Users/loschcode/.rvm/rubies/ruby-3.1.2/include/ruby-3.1.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
nokogiri_verify_with.c:183:22: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
    rsa_key_length = RSTRING_LEN(rb_rsa_key);
                   ~ ^~~~~~~~~~~~~~~~~~~~~~~
/Users/loschcode/.rvm/rubies/ruby-3.1.2/include/ruby-3.1.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
nokogiri_verify_with.c:212:54: warning: implicit conversion loses integer precision: 'time_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
    dsigCtx->keyInfoReadCtx.certsVerificationDepth = (time_t)NUM2LONG(rb_verification_depth);
                                                   ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 warnings generated.
compiling options.c
options.c:65:28: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  int blockEncryptionLen = RSTRING_LEN(rb_block_encryption);
      ~~~~~~~~~~~~~~~~~~   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/loschcode/.rvm/rubies/ruby-3.1.2/include/ruby-3.1.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
options.c:67:25: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  int keyTransportLen = RSTRING_LEN(rb_key_transport);
      ~~~~~~~~~~~~~~~   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/loschcode/.rvm/rubies/ruby-3.1.2/include/ruby-3.1.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
options.c:108:43: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
  unsigned int signatureAlgorithmLength = RSTRING_LEN(rb_signature_alg);
               ~~~~~~~~~~~~~~~~~~~~~~~~   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/loschcode/.rvm/rubies/ruby-3.1.2/include/ruby-3.1.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
options.c:149:40: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
  unsigned int digestAlgorithmLength = RSTRING_LEN(rb_digest_alg);
               ~~~~~~~~~~~~~~~~~~~~~   ^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/loschcode/.rvm/rubies/ruby-3.1.2/include/ruby-3.1.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
4 warnings generated.
compiling shutdown.c
compiling util.c
linking shared-object nokogiri_ext_xmlsec.bundle
Undefined symbols for architecture arm64:
  "_noko_xml_document_pin_node", referenced from:
      _decrypt_with_key in nokogiri_decrypt_with_key.o
  "_noko_xml_node_wrap", referenced from:
      _get_id in nokogiri_helpers_set_attribute_id.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [nokogiri_ext_xmlsec.bundle] Error 1

make failed, exit code 2

@flavorjones
Copy link

Can you please also reply with the Makefile that's generated? It should be somewhere like .../ruby/3.1.2/gems/nokogiri-xmlsec-instructure-0.10.1/ext/nokogiri_ext_xmlsec/Makefile

@Loschcode
Copy link
Author

Hi, here's the Makefile


SHELL = /bin/sh

# V=0 quiet, V=1 verbose.  other values don't work.
V = 0
V0 = $(V:0=)
Q1 = $(V:1=)
Q = $(Q1:0=@)
ECHO1 = $(V:1=@ :)
ECHO = $(ECHO1:0=@ echo)
NULLCMD = :

#### Start of system configuration section. ####

srcdir = .
topdir = /Users/loschcode/.rvm/rubies/ruby-3.1.2/include/ruby-3.1.0
hdrdir = $(topdir)
arch_hdrdir = /Users/loschcode/.rvm/rubies/ruby-3.1.2/include/ruby-3.1.0/arm64-darwin21
PATH_SEPARATOR = :
VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
prefix = $(DESTDIR)/Users/loschcode/.rvm/rubies/ruby-3.1.2
rubysitearchprefix = $(rubylibprefix)/$(sitearch)
rubyarchprefix = $(rubylibprefix)/$(arch)
rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
exec_prefix = $(prefix)
vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
sitearchhdrdir = $(sitehdrdir)/$(sitearch)
rubyarchhdrdir = $(rubyhdrdir)/$(arch)
vendorhdrdir = $(rubyhdrdir)/vendor_ruby
sitehdrdir = $(rubyhdrdir)/site_ruby
rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
vendorarchdir = $(vendorlibdir)/$(sitearch)
vendorlibdir = $(vendordir)/$(ruby_version)
vendordir = $(rubylibprefix)/vendor_ruby
sitearchdir = $(DESTDIR)./.gem.20221021-83417-i8fhxh
sitelibdir = $(DESTDIR)./.gem.20221021-83417-i8fhxh
sitedir = $(rubylibprefix)/site_ruby
rubyarchdir = $(rubylibdir)/$(arch)
rubylibdir = $(rubylibprefix)/$(ruby_version)
sitearchincludedir = $(includedir)/$(sitearch)
archincludedir = $(includedir)/$(arch)
sitearchlibdir = $(libdir)/$(sitearch)
archlibdir = $(libdir)/$(arch)
ridir = $(datarootdir)/$(RI_BASE_NAME)
mandir = $(datarootdir)/man
localedir = $(datarootdir)/locale
libdir = $(exec_prefix)/lib
psdir = $(docdir)
pdfdir = $(docdir)
dvidir = $(docdir)
htmldir = $(docdir)
infodir = $(datarootdir)/info
docdir = $(datarootdir)/doc/$(PACKAGE)
oldincludedir = $(DESTDIR)/usr/include
includedir = $(SDKROOT)$(prefix)/include
runstatedir = $(localstatedir)/run
localstatedir = $(prefix)/var
sharedstatedir = $(prefix)/com
sysconfdir = $(prefix)/etc
datadir = $(datarootdir)
datarootdir = $(prefix)/share
libexecdir = $(exec_prefix)/libexec
sbindir = $(exec_prefix)/sbin
bindir = $(exec_prefix)/bin
archdir = $(rubyarchdir)


CC_WRAPPER = 
CC = gcc
CXX = g++
LIBRUBY = $(LIBRUBY_SO)
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static -framework CoreFoundation $(MAINLIBS)
empty =
OUTFLAG = -o $(empty)
COUTFLAG = -o $(empty)
CSRCFLAG = $(empty)

RUBY_EXTCONF_H = 
cflags   = -fdeclspec $(optflags) $(debugflags) $(warnflags)
cxxflags = 
optflags = -O3 -fno-fast-math
debugflags = -ggdb3
warnflags = -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef
cppflags = 
CCDLFLAGS = -fno-common
CFLAGS   = $(CCDLFLAGS) -O3 -I/opt/homebrew/opt/libyaml/include -I/opt/homebrew/opt/libksba/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/zlib/include -I/opt/homebrew/opt/openssl@1.1/include $(cflags) -fno-common -pipe -D__XMLSEC_FUNCTION__=__func__ -DXMLSEC_NO_SIZE_T -DXMLSEC_NO_GOST=1 -DXMLSEC_NO_GOST2012=1 -DXMLSEC_NO_CRYPTO_DYNAMIC_LOADING=1 -DXMLSEC_CRYPTO_OPENSSL=1 -D__XMLSEC_FUNCTION__=__func__ -DXMLSEC_NO_SIZE_T -DXMLSEC_NO_GOST=1 -DXMLSEC_NO_GOST2012=1 -DXMLSEC_NO_CRYPTO_DYNAMIC_LOADING=1 -I/opt/homebrew/Cellar/libxmlsec1/1.2.34_1/include/xmlsec1 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -I/opt/homebrew/opt/openssl@1.1/include -I/opt/homebrew/opt/openssl@1.1/include/openssl -DXMLSEC_CRYPTO_OPENSSL=1 -fvisibility=hidden $(ARCH_FLAG)
INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir) -I/opt/homebrew/Cellar/libxmlsec1/1.2.34_1/include/xmlsec1 -I/opt/homebrew/opt/openssl@1.1/include -I/opt/homebrew/opt/openssl@1.1/include/openssl
DEFS     = 
CPPFLAGS = -DHAVE_RUBY_H -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT $(DEFS) $(cppflags)
CXXFLAGS = $(CCDLFLAGS) -fdeclspec -D__XMLSEC_FUNCTION__=__func__ -DXMLSEC_NO_SIZE_T -DXMLSEC_NO_GOST=1 -DXMLSEC_NO_GOST2012=1 -DXMLSEC_NO_CRYPTO_DYNAMIC_LOADING=1 -DXMLSEC_CRYPTO_OPENSSL=1 $(ARCH_FLAG)
ldflags  = -L. -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/libksba/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/zlib/lib -L/opt/homebrew/opt/openssl@1.1/lib -fstack-protector-strong -L/usr/local/lib -L/opt/homebrew/Cellar/libxmlsec1/1.2.34_1/lib -L/opt/homebrew/opt/openssl@1.1/lib
dldflags = -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/libksba/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/zlib/lib -L/opt/homebrew/opt/openssl@1.1/lib -Wl,-multiply_defined,suppress 
ARCH_FLAG = 
DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
LDSHARED = $(CC) -dynamic -bundle
LDSHAREDXX = $(CXX) -dynamic -bundle
AR = ar
EXEEXT = 

RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
RUBY_SO_NAME = ruby.3.1
RUBYW_INSTALL_NAME = 
RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
RUBYW_BASE_NAME = rubyw
RUBY_BASE_NAME = ruby

arch = arm64-darwin21
sitearch = $(arch)
ruby_version = 3.1.0
ruby = $(bindir)/$(RUBY_BASE_NAME)
RUBY = $(ruby)
ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/backward.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h

RM = rm -f
RM_RF = rm -fr
RMDIRS = rmdir -p
MAKEDIRS = /opt/homebrew/opt/coreutils/bin/gmkdir -p
INSTALL = /opt/homebrew/opt/coreutils/bin/ginstall -c
INSTALL_PROG = $(INSTALL) -m 0755
INSTALL_DATA = $(INSTALL) -m 644
COPY = cp
TOUCH = exit >

#### End of system configuration section. ####

preload = 
libpath = . $(libdir)
LIBPATH =  -L. -L$(libdir)
DEFFILE = 

CLEANFILES = mkmf.log
DISTCLEANFILES = 
DISTCLEANDIRS = 

extout = 
extout_prefix = 
target_prefix = 
LOCAL_LIBS = 
LIBS = $(LIBRUBYARG_SHARED) -L/opt/homebrew/Cellar/libxmlsec1/1.2.34_1/lib -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib -L/opt/homebrew/opt/openssl@1.1/lib -lxmlsec1-openssl -lxmlsec1 -lxslt -lxml2 -lz -lpthread -licucore -lm -lcrypto  
ORIG_SRCS = init.c nokogiri_decrypt_with_key.c nokogiri_encrypt_with_key.c nokogiri_helpers_set_attribute_id.c nokogiri_init.c nokogiri_sign.c nokogiri_verify_with.c options.c shutdown.c util.c
SRCS = $(ORIG_SRCS) 
OBJS = init.o nokogiri_decrypt_with_key.o nokogiri_encrypt_with_key.o nokogiri_helpers_set_attribute_id.o nokogiri_init.o nokogiri_sign.o nokogiri_verify_with.o options.o shutdown.o util.o
HDRS = $(srcdir)/common.h $(srcdir)/options.h $(srcdir)/util.h $(srcdir)/xmlsecrb.h
LOCAL_HDRS = 
TARGET = nokogiri_ext_xmlsec
TARGET_NAME = nokogiri_ext_xmlsec
TARGET_ENTRY = Init_$(TARGET_NAME)
DLLIB = $(TARGET).bundle
EXTSTATIC = 
STATIC_LIB = 

TIMESTAMP_DIR = .
BINDIR        = $(bindir)
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
RUBYLIBDIR    = $(sitelibdir)$(target_prefix)
RUBYARCHDIR   = $(sitearchdir)$(target_prefix)
HDRDIR        = $(sitehdrdir)$(target_prefix)
ARCHHDRDIR    = $(sitearchhdrdir)$(target_prefix)
TARGET_SO_DIR =
TARGET_SO     = $(TARGET_SO_DIR)$(DLLIB)
CLEANLIBS     = $(TARGET_SO) $(TARGET_SO).dSYM
CLEANOBJS     = *.o  *.bak

all:    $(DLLIB)
static: $(STATIC_LIB)
.PHONY: all install static install-so install-rb
.PHONY: clean clean-so clean-static clean-rb

clean-static::
clean-rb-default::
clean-rb::
clean-so::
clean: clean-so clean-static clean-rb-default clean-rb
		-$(Q)$(RM_RF) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time

distclean-rb-default::
distclean-rb::
distclean-so::
distclean-static::
distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
		-$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
		-$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
		-$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true

realclean: distclean
install: install-so install-rb

install-so: $(DLLIB) $(TIMESTAMP_DIR)/.sitearchdir.time
	$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
clean-static::
	-$(Q)$(RM) $(STATIC_LIB)
install-rb: pre-install-rb do-install-rb install-rb-default
install-rb-default: pre-install-rb-default do-install-rb-default
pre-install-rb: Makefile
pre-install-rb-default: Makefile
do-install-rb:
do-install-rb-default:
pre-install-rb-default:
	@$(NULLCMD)
$(TIMESTAMP_DIR)/.sitearchdir.time:
	$(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
	$(Q) $(TOUCH) $@

site-install: site-install-so site-install-rb
site-install-so: install-so
site-install-rb: install-rb

.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S

.cc.o:
	$(ECHO) compiling $(<)
	$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<

.cc.S:
	$(ECHO) translating $(<)
	$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<

.mm.o:
	$(ECHO) compiling $(<)
	$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<

.mm.S:
	$(ECHO) translating $(<)
	$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<

.cxx.o:
	$(ECHO) compiling $(<)
	$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<

.cxx.S:
	$(ECHO) translating $(<)
	$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<

.cpp.o:
	$(ECHO) compiling $(<)
	$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<

.cpp.S:
	$(ECHO) translating $(<)
	$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<

.c.o:
	$(ECHO) compiling $(<)
	$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<

.c.S:
	$(ECHO) translating $(<)
	$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<

.m.o:
	$(ECHO) compiling $(<)
	$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<

.m.S:
	$(ECHO) translating $(<)
	$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<

$(TARGET_SO): $(OBJS) Makefile
	$(ECHO) linking shared-object $(DLLIB)
	-$(Q)$(RM) $(@)
	$(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
	$(Q) $(POSTLINK)



$(OBJS): $(HDRS) $(ruby_headers)

@flavorjones
Copy link

Ah, OK, here's a big difference between my Makefile and yours, and I believe it's related to how your Ruby was configured when it was built and installed.

On MacOS, clang will not allow any unresolved symbols at link time (some discussion which explains a bit more is at this SO post) unless the linked is explicitly told to with a flag like -Wl,-undefined,dynamic_lookup.

On my machine, this is present in RbConfig::CONFIG["DLDFLAGS"] and so ends up in the Makefile at:

dldflags = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -L/opt/homebrew/opt/openssl@1.1/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/gdbm/lib

This flag doesn't appear in your Makefile, and I think that's the reason this is happening to you and not to me. When I remove that flag from my Makefile and build, I see the same error as you:

linking shared-object nokogiri_ext_xmlsec.bundle
Undefined symbols for architecture arm64:
  "_noko_xml_document_pin_node", referenced from:
      _decrypt_with_key in nokogiri_decrypt_with_key.o
  "_noko_xml_node_wrap", referenced from:
      _get_id in nokogiri_helpers_set_attribute_id.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [nokogiri_ext_xmlsec.bundle] Error 1

There doesn't seem to be an easy workaround, the Makefile doesn't allow injection of additional linker flags via environment variables as far as I can tell.

Can you say a bit about how your Ruby was built?

@Loschcode
Copy link
Author

Well, I just used rvm and installed it through a simple rvm install and don't know much details about the difference with another way of doing it, but if need be, I can absolutely remove it and work on an alternative. What's the difference with your Ruby?

@flavorjones
Copy link

On my M1 I use https://github.com/postmodern/ruby-install (which you can install with homebrew) to install Rubies from source.

@flavorjones
Copy link

There's a potentially related thread right now in the ruby-build project which seems to indicate something changed in XCode 14.

https://bugs.ruby-lang.org/issues/18912

In any case, you may want to make sure your Ruby is built with the --enable-shared configuration option?

@Loschcode
Copy link
Author

I've tried installing ruby through ruby-install but it fails

linking shared-object -test-/RUBY_ALIGNOF.bundle
compiling extract.c
linking shared-object -test-/arith_seq/extract.bundle
Undefined symbols for architecture arm64:
  "_rb_arithmetic_sequence_extract", referenced from:
      _arith_seq_s_extract in extract.o
  "_rb_ary_new_capa", referenced from:
      _arith_seq_s_extract in extract.o
  "_rb_ary_store", referenced from:
      _arith_seq_s_extract in extract.o
  "_rb_define_singleton_method", referenced from:
      _Init_extract in extract.o
  "_rb_path2class", referenced from:
      _Init_extract in extract.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [../../../../.ext/arm64-darwin22/-test-/arith_seq/extract.bundle] Error 1
make[1]: *** [ext/-test-/arith_seq/extract/all] Error 2
make: *** [build-ext] Error 2
!!! Compiling ruby 3.1.0 failed!

Also I've tried downgrading to Xcode 13.4 because it's what your link recommend, but it fails too

Command Line Tools can't be installed on this disk. The version of macOS is too new.

I feel really stuck and unlucky, I'll try out the --enable-shared option

@Loschcode
Copy link
Author

I've tried to reinstall Ruby through rvm install 3.1.0 -C --enable-shared but it still crashes the same way 😢 thanks for the advice, but it feels like XCode is being a problem but I can't even downgrade it 🤔

@Loschcode
Copy link
Author

Big news today, after investigating further and going through this link, I could build your gem with this command

gem install nokogiri-xmlsec-instructure -- --with-ldflags="-Wl,-undefined,dynamic_lookup"

Not sure what those exact flags mean, I just copied it from the issue, but it's progress. Now I've to see how to do the same through bundle

@Loschcode
Copy link
Author

For anyone interested and facing this problem, the solution to bundle install a project with this issue is to type this before

bundle config build.nokogiri-xmlsec-instructure --with-ldflags="-Wl,-undefined,dynamic_lookup"

@Loschcode
Copy link
Author

@flavorjones thanks for following up with this problem and being super reactive, that helped me a lot. Cheers 🤘 happy Halloween and have a good week!

@flavorjones
Copy link

Great! I'm glad you found a workaround. Thanks for closing the loop!

@maths22
Copy link
Member

maths22 commented Dec 14, 2022

FYI -Wl,-undefined,dynamic_lookup has been added to the buildscript for this gem, so this should be a non-issue for the latest version

@SamMalcolm
Copy link

For anyone interested and facing this problem, the solution to bundle install a project with this issue is to type this before

bundle config build.nokogiri-xmlsec-instructure --with-ldflags="-Wl,-undefined,dynamic_lookup"

This fixed this issue for me tysm! I was running out of hair to pull out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants