Emerging R fails post install, blaming that invalid install_name was found, and that the application or library will crash at runtime. Reproducible: Always Steps to Reproduce: emerge "=dev-lang/R-4.3.1" Actual Results: * ERROR: dev-lang/R-4.3.1::gentoo_prefix failed: * invalid install_name found, your application or library will crash at runtime * * Call stack: * misc-functions.sh, line 861: Called install_qa_check * misc-functions.sh, line 186: Called install_qa_check_macho * misc-functions.sh, line 442: Called die * The specific snippet of code: * has allow_broken_install_names ${FEATURES} || \ * die "invalid install_name found, your application or library will crash at runtime" * * If you need support, post the output of `emerge --info '=dev-lang/R-4.3.1::gentoo_prefix'`, * the complete build log and the output of `emerge -pqv '=dev-lang/R-4.3.1::gentoo_prefix'`. * The complete build log is located at '/Users/askarbektassov/Gentoo/var/tmp/portage/dev-lang/R-4.3.1/temp/build.log'. * The ebuild environment file is located at '/Users/askarbektassov/Gentoo/var/tmp/portage/dev-lang/R-4.3.1/temp/environment'. * Working directory: '/Users/askarbektassov/Gentoo/var/tmp/portage/dev-lang/R-4.3.1/image' * S: '/Users/askarbektassov/Gentoo/var/tmp/portage/dev-lang/R-4.3.1/work/R-4.3.1' !!! post install failed; exiting. Expected Results: Successful emerge Despite the complains, R has been merged into the working tree and can be called (unsure why with Italian locale). However, it was not added to the world file. askarbektassov@Askars-MBP ~ $ locale LANG="" LC_COLLATE="C" LC_CTYPE="C" LC_MESSAGES="C" LC_MONETARY="C" LC_NUMERIC="C" LC_TIME="C" LC_ALL= askarbektassov@Askars-MBP ~ $ R R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid" Copyright (C) 2022 The R Foundation for Statistical Computing Platform: aarch64-apple-darwin20 (64-bit) R è un software libero ed è rilasciato SENZA ALCUNA GARANZIA. Siamo ben lieti se potrai redistribuirlo, ma sotto certe condizioni. Scrivi 'license()' o 'licence()' per maggiori dettagli. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Scrivi 'demo()' per una dimostrazione, 'help()' per la guida oppure 'help.start()' per la guida nel browser HTML. Scrivi 'q()' per uscire da R. askarbektassov@Askars-MBP ~ $ cat Gentoo/var/lib/portage/world | grep R askarbektassov@Askars-MBP ~ $
Created attachment 866771 [details] emerge --info
Created attachment 866772 [details] build.log
I wonder if the issue with locale has anything to do with the following QA Notice I receive post installation. * QA Notice: Found the following implicit function declarations in configure logs: * /Users/askarbektassov/Gentoo/var/tmp/portage/dev-lang/R-4.3.1/work/R-4.3.1/config.log:62826 - _NL_LOCALE_NAME * Check that no features were accidentally disabled. * See https://wiki.gentoo.org/wiki/Modern_C_porting. * QA Notice: invalid self-reference install_name libRmath.dylib in //Users/askarbektassov/Gentoo/usr/lib/libRmath.dylib
_NL_ is glibc imo, so we should check if there's a musl patch, or why it believes we're having glibc
So, apparently with ChatGPT I managed to complete the merging of the package. askarbektassov@Askars-MBP ~ $ ebuild /Users/askarbektassov/Gentoo/var/db/repos/gentoo/dev-lang/R/R-4.3.1.ebuild compile askarbektassov@Askars-MBP ~ $ install_name_tool -id @rpath/libRmath.dylib /Users/askarbektassov/Gentoo/var/tmp/portage/dev-lang/R-4.3.1/work/R-4.3.1/src/nmath/standalone/libRmath.dylib askarbektassov@Askars-MBP ~ $ ebuild /Users/askarbektassov/Gentoo/var/db/repos/gentoo/dev-lang/R/R-4.3.1.ebuild install qmerge clean
So, I have no idea what I did. No idea what (or if) I fixed; and certainly I do not feel smarter (actually the opposite), but it is so cool seeing a chatbot that gives me a hint with just a single paste of an error. Also, I noticed that the ebuild is called R-4.3.1.ebuild, but the actual version when I run R is 4.2.1 (see initial post).
(In reply to Askar Bektassov from comment #5) > So, apparently with ChatGPT I managed to complete the merging of the package. > > askarbektassov@Askars-MBP ~ $ ebuild > /Users/askarbektassov/Gentoo/var/db/repos/gentoo/dev-lang/R/R-4.3.1.ebuild > compile > > askarbektassov@Askars-MBP ~ $ install_name_tool -id @rpath/libRmath.dylib > /Users/askarbektassov/Gentoo/var/tmp/portage/dev-lang/R-4.3.1/work/R-4.3.1/ > src/nmath/standalone/libRmath.dylib > > askarbektassov@Askars-MBP ~ $ ebuild > /Users/askarbektassov/Gentoo/var/db/repos/gentoo/dev-lang/R/R-4.3.1.ebuild > install qmerge clean After merging it should be 4.3.1, no longer 4.2 > * QA Notice: invalid self-reference install_name libRmath.dylib in //Users/askarbektassov/Gentoo/usr/lib/libRmath.dylib This is the QA check that forbade the merge to finish. I don't completely understand the root cause. I ignored it and merged it like you, and R works fine. So the QA check needs to be re-evaluated.
I wonder if I should report a separate bug, or if this is an upstream issue. Assume you want to create a column vector. What I get with R (gentoo-prefix) is the following: > matrix(c(1,2,3),ncol=1) [,1] [4294967297,] 1 [2,] 2 [3,] 3 does not matter how the matrix is created > matrix(rnorm(3),ncol=1) [,1] [4294967297,] -0.05146677 [2,] -1.28747560 [3,] -0.38765110 While I was expecting something like the following (R as part of RStudio) > matrix(c(1,2,3),ncol=1) [,1] [1,] 1 [2,] 2 [3,] 3 > matrix(rnorm(3),ncol=1) [,1] [1,] -0.2529536 [2,] 0.7767808 [3,] 1.5219928
(In reply to Askar Bektassov from comment #8) > I wonder if I should report a separate bug, or if this is an upstream issue. > > Assume you want to create a column vector. What I get with R (gentoo-prefix) > is the following: > > > matrix(c(1,2,3),ncol=1) > [,1] > [4294967297,] 1 > [2,] 2 > [3,] 3 > > does not matter how the matrix is created > > > matrix(rnorm(3),ncol=1) > [,1] > [4294967297,] -0.05146677 > [2,] -1.28747560 > [3,] -0.38765110 > > While I was expecting something like the following (R as part of RStudio) > > > matrix(c(1,2,3),ncol=1) > [,1] > [1,] 1 > [2,] 2 > [3,] 3 > > > matrix(rnorm(3),ncol=1) > [,1] > [1,] -0.2529536 > [2,] 0.7767808 > [3,] 1.5219928 I could not reproduce it with x86_64-apple-darwin20 (macOS 11.0) $ R R version 4.3.1 (2023-06-16) -- "Beagle Scouts" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-apple-darwin20 (64-bit) ... > matrix(c(1,2,3),ncol=1) [,1] [1,] 1 [2,] 2 [3,] 3 >
I tried to recompile again... and the issue remains. askarbektassov@Askars-MBP ~ $ R R version 4.3.1 (2023-06-16) -- "Beagle Scouts" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: aarch64-apple-darwin21 (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > matrix(rnorm(3),ncol=1) [,1] [4294967297,] -0.93388084 [2,] -2.38337839 [3,] -0.09858127
I bet this is an arm64 problem. We had bugs before because of things like people assuming 0 and NULL are identical, which is not the case on this platform.
Then I wonder what can be the difference between me and Benda (who could not replicate the issue). askarbektassov@Askars-MBP ~ $ emerge --info Portage 3.0.49 (python 3.11.3-final-0, prefix/darwin/macos/12.0/arm64/gcc, gcc-12.2.0, unavailable, 22.5.0 arm64) ================================================================= System uname: macOS-13.4.1-arm64-arm-64bit Timestamp of repository gentoo_prefix: Thu, 10 Aug 2023 08:26:25 +0000 Head commit of repository gentoo_prefix: ee91122dc117a4f3ef5dcc12677a3e5e1bcac25c sh bash 5.2_p15-r6 app-misc/pax-utils: 1.3.7::gentoo_prefix app-shells/bash: 5.2_p15-r6::gentoo_prefix dev-lang/perl: 5.38.0-r1::gentoo_prefix dev-lang/python: 3.11.3::gentoo_prefix dev-util/cmake: 3.27.1::gentoo_prefix dev-util/meson: 1.2.0::gentoo_prefix sys-apps/baselayout: 2.14::gentoo_prefix sys-devel/autoconf: 2.71-r7::gentoo_prefix sys-devel/automake: 1.16.5-r1::gentoo_prefix sys-devel/binutils-config: 5.1-r5::gentoo_prefix sys-devel/gcc: 12.2.0-r2::gentoo_prefix sys-devel/gcc-config: 2.7-r1::gentoo_prefix sys-devel/libtool: 2.4.7-r1::gentoo_prefix sys-devel/make: 4.4.1-r1::gentoo_prefix Repositories: gentoo_prefix location: /Users/askarbektassov/Gentoo/var/db/repos/gentoo sync-type: rsync sync-uri: rsync://rsync.prefix.bitzolder.nl/gentoo-portage-prefix priority: -1000 aliases: gentoo volatile: True sync-rsync-verify-jobs: 1 sync-rsync-verify-max-age: 24 sync-rsync-extra-opts: sync-rsync-verify-metamanifest: no a5kar location: /Users/askarbektassov/Gentoo/var/db/repos/a5kar masters: gentoo_prefix volatile: True ACCEPT_KEYWORDS="~arm64-macos ~x64-macos" ACCEPT_LICENSE="@FREE" CBUILD="arm64-apple-darwin21" CFLAGS=" -O2 -pipe" CHOST="arm64-apple-darwin21" CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release" CONFIG_SHELL="/Users/askarbektassov/Gentoo/bin/bash" CXXFLAGS=" -O2 -pipe" DISTDIR="/Users/askarbektassov/Gentoo/var/cache/distfiles" ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME" FCFLAGS="" FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live case-insensitive-fs config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news nostrip parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sfperms strict unknown-features-warn unmerge-logs unmerge-orphans unprivileged" FFLAGS="" GENTOO_MIRRORS="http://distfiles.gentoo.org http://distfiles.prefix.bitzolder.nl/prefix" LDFLAGS="-Wl,-dead_strip_dylibs" LEX="flex" MAKEOPTS="-j6" PKGDIR="/Users/askarbektassov/Gentoo/var/cache/binpkgs" PORTAGE_CONFIGROOT="/Users/askarbektassov/Gentoo/" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git" PORTAGE_TMPDIR="/Users/askarbektassov/Gentoo/var/tmp" SHELL="/Users/askarbektassov/Gentoo/bin/zsh" USE="aqua arm64-macos bzip2 coreaudio gdbm ipv6 ncurses nls nptl objc objc++ prefix prefix-guest readline ssl test-rust unicode zlib" ADA_TARGET="gnat_2021" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_ARM="aes crc32 edsp neon sha1 sha2 v4 v5 v6 v7 v8 vfp vfp-d32 vfpv3 vfpv4" ELIBC="Darwin" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="Darwin" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php8-1" POSTGRES_TARGETS="postgres15" PYTHON_SINGLE_TARGET="python3_11" PYTHON_TARGETS="python3_11" RUBY_TARGETS="ruby32" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account" Unset: ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EMERGE_DEFAULT_OPTS, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LANG, LC_ALL, LD, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS
benda: x86_64-apple-darwin20 askar: aarch64-apple-darwin21 I don't think darwin20 vs darwin21 is the issue. x86_64 vs aarch64 (arm64) is.
Right, completely missed that. For some reason I assumed that benda also had arm64. Do you suggest filing this bug upstream?
yes, I think it's time to bring it up with them
Adding the following lines to R-4.3.2-r1.ebuild helps compilation. --- old/R-4.3.2-r1.ebuild 2024-04-24 07:26:04.527492128 +0200 +++ new/R-4.3.2-r1.ebuild 2024-04-28 14:05:30.759570416 +0200 @@ -202,6 +202,15 @@ install_name_tool -id "${EPREFIX}/usr/$(get_libdir)/R/${mod}" "${mod}" done popd >/dev/null || die + + # Fix for dylib files that for some reason are not in lib/R + # such as libRmath.dylib + pushd "${ED}"/usr/$(get_libdir) >/dev/null || die + for mod in $(find . -name "*.dylib") ; do + mod=${mod#./} + install_name_tool -id "${EPREFIX}/usr/$(get_libdir)/${mod}" "${mod}" + done + popd >/dev/null || die fi # Users are encouraged to access some of the the R documentation However, the issue of having weird index for the first row in matrices remains. askarbektassov@Askars-MBP ~ $ R R version 4.3.2 (2023-10-31) -- "Eye Holes" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: aarch64-apple-darwin21 (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > matrix(1) [,1] [4294967297,] 1 >
I suspect there is some integer overflow, since 4,294,967,297 = 2^32 + 1. Or maybe misalignment somewhere that indices are either 32 bit, or 64 bit. When I built R with use="lapack lto", even the column indices turned to a weird number. > matrix(1) [,4294967297] [4294967297,] 1 I tried submitting a bug upstream, but they believe its an issue with portage, because hey cannot reproduce this.
I think your patch could be as simple as amending the lib/R install_name_tool-ing. I don't see any weird going on in the ebuild, except we compile with gcc, and upstream likely compiles with clang.
(In reply to Askar Bektassov from comment #17) > > I tried submitting a bug upstream, but they believe its an issue with > portage, because hey cannot reproduce this. Please give a link to whatever you submitted, if it's public.
(In reply to Sam James from comment #19) > (In reply to Askar Bektassov from comment #17) > > > > I tried submitting a bug upstream, but they believe its an issue with > > portage, because hey cannot reproduce this. > > Please give a link to whatever you submitted, if it's public. https://bugs.r-project.org/show_bug.cgi?id=18578
I am starting to have a suspition that the problem maybe somewhere in the lapack/blas library used by R. By default, portage installed virtual/blas, which I believe is due to BLAS libraries already included in sci-libs/lapack package. I would like to see if I could compile sci-libs/openblas instead and then link R to it. To do this, it may be beneficial using eselect-ldso, that would allow me switching from different instances of BLAS libraries. But I see it this flag is masked everywhere, and even creating a package.use.mask folder with -eselect-ldso does not help. Am I doing something wrong? Or, is there a good reason eselect-ldso is not being allowed on a gentoo prefix?
(In reply to Askar Bektassov from comment #21) > I am starting to have a suspition that the problem maybe somewhere in the > lapack/blas library used by R. > > By default, portage installed virtual/blas, which I believe is due to BLAS > libraries already included in sci-libs/lapack package. I would like to see > if I could compile sci-libs/openblas instead and then link R to it. > > To do this, it may be beneficial using eselect-ldso, that would allow me > switching from different instances of BLAS libraries. But I see it this flag > is masked everywhere, and even creating a package.use.mask folder with > -eselect-ldso does not help. > > Am I doing something wrong? Or, is there a good reason eselect-ldso is not > being allowed on a gentoo prefix? The Prefix on macOS is implemented in rpath. But eselect-ldso, is, ld.so of glibc. We have a way to do this on macOS.