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

[R] Support gnu libtool? #40248

Closed
jonkeane opened this issue Feb 26, 2024 · 10 comments
Closed

[R] Support gnu libtool? #40248

jonkeane opened this issue Feb 26, 2024 · 10 comments

Comments

@jonkeane
Copy link
Member

Describe the enhancement requested

We currently are failing on most macOS systems on CRAN. It appears that the CRAN runners have GNU libtool installed instead of the xcode version so we need to avoid '-no_warning_for_no_symbols'.

Note: the mac builder CRAN machine does not exhibit this behavior. So we will need to test this on our own.

[ 19%] Bundling /var/folders/k4/0jwzxmln0nb8y6rkzprptb640000gq/T/Rtmp4C6n7h/file63de2525b3fd/release/libarrow_bundled_dependencies.a
Scanning dependencies of target arrow_dependencies
Usage: /Library/Frameworks/R.framework/Resources/bin/libtool [OPTION]... [MODE-ARG]...
Try 'libtool --help' for more information.
libtool:   error: unrecognised option: '-no_warning_for_no_symbols'
make[2]: *** [src/arrow/CMakeFiles/arrow_bundled_dependencies_merge] Error 1
make[1]: *** [src/arrow/CMakeFiles/arrow_bundled_dependencies_merge.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 19%] Built target arrow_dependencies
make: *** [all] Error 2
**** Complete build log may still be present at /var/folders/k4/0jwzxmln0nb8y6rkzprptb640000gq/T//Rtmp4C6n7h/file63de4e4bba18.log 
*** Failed to find Arrow C++ libraries.
------------------------- NOTE ---------------------------
There was an issue preparing the Arrow C++ libraries.
See https://arrow.apache.org/docs/r/articles/install.html
----------------------------------------------------------

Component(s)

R

@kou
Copy link
Member

kou commented Feb 27, 2024

Does this work?

diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake
index 083ac2fe9a..c8da0d43d4 100644
--- a/cpp/cmake_modules/BuildUtils.cmake
+++ b/cpp/cmake_modules/BuildUtils.cmake
@@ -96,10 +96,7 @@ function(arrow_create_merged_static_lib output_target)
     list(APPEND all_library_paths $<TARGET_FILE:${lib}>)
   endforeach()
 
-  if(APPLE)
-    set(BUNDLE_COMMAND "libtool" "-no_warning_for_no_symbols" "-static" "-o"
-                       ${output_lib_path} ${all_library_paths})
-  elseif(CMAKE_CXX_COMPILER_ID MATCHES "^(Clang|GNU|Intel|IntelLLVM)$")
+  if(CMAKE_CXX_COMPILER_ID MATCHES "^(Clang|GNU|Intel|IntelLLVM)$")
     set(ar_script_path ${CMAKE_BINARY_DIR}/${ARG_NAME}.ar)
 
     file(WRITE ${ar_script_path}.in "CREATE ${output_lib_path}\n")
@@ -120,7 +117,9 @@ function(arrow_create_merged_static_lib output_target)
     endif()
 
     set(BUNDLE_COMMAND ${ar_tool} -M < ${ar_script_path})
-
+  elseif(APPLE)
+    set(BUNDLE_COMMAND "libtool" "-no_warning_for_no_symbols" "-static" "-o"
+                       ${output_lib_path} ${all_library_paths})
   elseif(MSVC)
     if(CMAKE_LIBTOOL)
       set(BUNDLE_TOOL ${CMAKE_LIBTOOL})

@kou
Copy link
Member

kou commented Feb 27, 2024

BTW, can we see all build log?

@jonkeane
Copy link
Member Author

jonkeane commented Feb 27, 2024

Oh, yes, I can try that as well — when I tried that locally I saw errors with arguments being passed to ar / ranlib (where the apple version doesn't accept the same as the non-apple version). But I'll try with the reversed order – it's also possible I messed something else up when I was doing that.

@jonkeane
Copy link
Member Author

Ok I've tried swapping those if/else blocks (locally) and on macOS we still hit the APPLE only block (the compiler ID is "AppleClang", so that's not totally surprising)

@jonkeane
Copy link
Member Author

I also tried adding AppleClang to the list of enumerated compiler ids and here is that AR command mismatch I got:

[ 11%] Performing install step for 'lz4_ep'
-- lz4_ep install command succeeded.  See also /var/folders/b2/8w36qffn5rgbkzd2bf8tcgbh0000gn/T/RtmpUYYlct/file361952aacb3a/lz4_ep-prefix/src/lz4_ep-stamp/lz4_ep-install-*.log
[ 12%] Completed 'lz4_ep'
[ 12%] Built target lz4_ep
-- re2_ep build command succeeded.  See also /var/folders/b2/8w36qffn5rgbkzd2bf8tcgbh0000gn/T/RtmpUYYlct/file361952aacb3a/re2_ep-prefix/src/re2_ep-stamp/re2_ep-build-*.log
[ 12%] Performing install step for 're2_ep'
-- re2_ep install command succeeded.  See also /var/folders/b2/8w36qffn5rgbkzd2bf8tcgbh0000gn/T/RtmpUYYlct/file361952aacb3a/re2_ep-prefix/src/re2_ep-stamp/re2_ep-install-*.log
[ 12%] Completed 're2_ep'
[ 12%] Built target re2_ep
[ 12%] Built target toolchain
[ 13%] Bundling /var/folders/b2/8w36qffn5rgbkzd2bf8tcgbh0000gn/T/RtmpUYYlct/file361952aacb3a/release/libarrow_bundled_dependencies.a
usage:  ar -d [-TLsv] archive file ...
	ar -m [-TLsv] archive file ...
	ar -m [-abiTLsv] position archive file ...
	ar -p [-TLsv] archive [file ...]
	ar -q [-cTLsv] archive file ...
	ar -r [-cuTLsv] archive file ...
	ar -r [-abciuTLsv] position archive file ...
	ar -t [-TLsv] archive [file ...]
	ar -x [-ouTLsv] archive [file ...]
make[2]: *** [src/arrow/CMakeFiles/arrow_bundled_dependencies_merge] Error 1
make[1]: *** [src/arrow/CMakeFiles/arrow_bundled_dependencies_merge.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 13%] Built target arrow_dependencies

@kou
Copy link
Member

kou commented Feb 27, 2024

Ah, sorry. I should have explained the idea of the suggested patch.

In general, Apache Arrow C++ build uses Apple's C/C++ toolchain. So CMAKE_CXX_COMPILER_ID is AppleClang. In this case, if(CMAKE_CXX_COMPILER_ID MATCHES "^(Clang|GNU|Intel|IntelLLVM)$") isn't matched. if(APPLE) (Apple's libtool) is used.

If macOS + CRAN build does NOT use Apple's C/C++ toolchain (uses C/C++ toolchain provided by R.framework that also includes GNU libtool, gcc, g++, GNU ar and so on), CMAKE_CXX_COMPILER_ID may be GNU not AppleClang. In this case, if(CMAKE_CXX_COMPILER_ID MATCHES "^(Clang|GNU|Intel|IntelLLVM)$") (GNU ar) is used.

@jonkeane
Copy link
Member Author

Ah, right got it — in this case I don't think that CRAN is using a full toolchain in R.framework.

The most direct evidence is in the CRAN logs:

-- The C compiler identification is AppleClang 14.0.0.14000029
-- The CXX compiler identification is AppleClang 14.0.0.14000029

The bin dir of that framework also doesn't have too much there (though does have libtool!):

ls /Library/Frameworks/R.framework/Resources/bin 
BATCH		Rcmd		SHLIB		exec		qpdf
COMPILE		Rd2pdf		Stangle		fc-cache	rtags
INSTALL		Rdconv		Sweave		javareconf
LINK		Rdiff		build		libtool
R		Rprof		check		mkinstalldirs
REMOVE		Rscript		config		pager

@kou
Copy link
Member

kou commented Feb 28, 2024

Thanks!

The bin dir of that framework also doesn't have too much there (though does have libtool!):

Oh, why... OK. We need to choose your approach (#40259).

@jonkeane
Copy link
Member Author

Oh, why... OK.

😂

jonkeane added a commit that referenced this issue Feb 28, 2024
…40259)

### Rationale for this change

On the CRAN build machines the GNU libtool is on the path in front of the macOS libtool. Though these are named the same thing, they are actually very different and don't actually appear to be substitutes

I checked on a non-developer's machine to see if `/usr/bin/libtool` exists, and it did. So I believe we _should_ be ok with this even if xcode / command line tools haven't been installed.

One note: it's possible that we could get the GNU libtool in link mode to work with the right incantation (something like `libtool --mode=link --tag=CXX ${cmake_compiler} -o ...` but when I tried this I kept getting symbol not found errors. Ultimately, I think any mac that we are on will have the apple-provided libtool, so decided to go the route of finding it. 

### What changes are included in this PR?

When we detect we are on a GNU libtool, we look to `/usr/bin/libtool` instead.

### Are these changes tested?

Yes. See a broken config failing at #40259 (comment) and then the next one passes

### Are there any user-facing changes?

We will remain on CRAN

**This PR contains a "Critical Fix".**
* GitHub Issue: #40248

Lead-authored-by: Jonathan Keane <jkeane@gmail.com>
Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
Signed-off-by: Jonathan Keane <jkeane@gmail.com>
@jonkeane jonkeane added this to the 15.0.1 milestone Feb 28, 2024
@jonkeane
Copy link
Member Author

Issue resolved by pull request 40259
#40259

thisisnic pushed a commit that referenced this issue Mar 1, 2024
…40259)

### Rationale for this change

On the CRAN build machines the GNU libtool is on the path in front of the macOS libtool. Though these are named the same thing, they are actually very different and don't actually appear to be substitutes

I checked on a non-developer's machine to see if `/usr/bin/libtool` exists, and it did. So I believe we _should_ be ok with this even if xcode / command line tools haven't been installed.

One note: it's possible that we could get the GNU libtool in link mode to work with the right incantation (something like `libtool --mode=link --tag=CXX ${cmake_compiler} -o ...` but when I tried this I kept getting symbol not found errors. Ultimately, I think any mac that we are on will have the apple-provided libtool, so decided to go the route of finding it. 

### What changes are included in this PR?

When we detect we are on a GNU libtool, we look to `/usr/bin/libtool` instead.

### Are these changes tested?

Yes. See a broken config failing at #40259 (comment) and then the next one passes

### Are there any user-facing changes?

We will remain on CRAN

**This PR contains a "Critical Fix".**
* GitHub Issue: #40248

Lead-authored-by: Jonathan Keane <jkeane@gmail.com>
Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
Signed-off-by: Jonathan Keane <jkeane@gmail.com>
thisisnic pushed a commit to thisisnic/arrow that referenced this issue Mar 8, 2024
…U one (apache#40259)

### Rationale for this change

On the CRAN build machines the GNU libtool is on the path in front of the macOS libtool. Though these are named the same thing, they are actually very different and don't actually appear to be substitutes

I checked on a non-developer's machine to see if `/usr/bin/libtool` exists, and it did. So I believe we _should_ be ok with this even if xcode / command line tools haven't been installed.

One note: it's possible that we could get the GNU libtool in link mode to work with the right incantation (something like `libtool --mode=link --tag=CXX ${cmake_compiler} -o ...` but when I tried this I kept getting symbol not found errors. Ultimately, I think any mac that we are on will have the apple-provided libtool, so decided to go the route of finding it. 

### What changes are included in this PR?

When we detect we are on a GNU libtool, we look to `/usr/bin/libtool` instead.

### Are these changes tested?

Yes. See a broken config failing at apache#40259 (comment) and then the next one passes

### Are there any user-facing changes?

We will remain on CRAN

**This PR contains a "Critical Fix".**
* GitHub Issue: apache#40248

Lead-authored-by: Jonathan Keane <jkeane@gmail.com>
Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
Signed-off-by: Jonathan Keane <jkeane@gmail.com>
@jonkeane jonkeane modified the milestones: 15.0.1, 16.0.0 Mar 12, 2024
@raulcd raulcd modified the milestones: 16.0.0, 15.0.2 Mar 13, 2024
raulcd pushed a commit that referenced this issue Mar 13, 2024
…40259)

### Rationale for this change

On the CRAN build machines the GNU libtool is on the path in front of the macOS libtool. Though these are named the same thing, they are actually very different and don't actually appear to be substitutes

I checked on a non-developer's machine to see if `/usr/bin/libtool` exists, and it did. So I believe we _should_ be ok with this even if xcode / command line tools haven't been installed.

One note: it's possible that we could get the GNU libtool in link mode to work with the right incantation (something like `libtool --mode=link --tag=CXX ${cmake_compiler} -o ...` but when I tried this I kept getting symbol not found errors. Ultimately, I think any mac that we are on will have the apple-provided libtool, so decided to go the route of finding it. 

### What changes are included in this PR?

When we detect we are on a GNU libtool, we look to `/usr/bin/libtool` instead.

### Are these changes tested?

Yes. See a broken config failing at #40259 (comment) and then the next one passes

### Are there any user-facing changes?

We will remain on CRAN

**This PR contains a "Critical Fix".**
* GitHub Issue: #40248

Lead-authored-by: Jonathan Keane <jkeane@gmail.com>
Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
Signed-off-by: Jonathan Keane <jkeane@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants