Friday, January 03, 2020

Re: Failed to build www/ruby-passenger on mips64el/loongson again

Friendly ping. Also adding Jeremy to CC as he last worked on this port.

Xiyue Deng <manphiz@gmail.com> writes:

> Xiyue Deng <manphiz@gmail.com> writes:
>
>> Hi ports maintainers,
>>
>> Some time ago I reported that www/ruby-passenger failed to build on
>> mips64el/loongson due to a linker issue[1]. Last month the port has
>> been updated and I tried to give it another shot. Unfortunately it
>> failed again but due to another compilation error. I have attached the
>> build log and please take a look and suggest what to test next.
>>
>> Thanks!
>>
>> [1] https://marc.info/?l=openbsd-ports&m=152359916007397&w=2
>
> I tried to dig a little more despite my lack of understand of the rake
> system. It looks like rake doesn't take into account about
> environmental settings from ports build system, so any setting regarding
> the compiler/linker doesn't take effect at all - I verified it by
> manually changing the compiler settings to add "-v" and saw that it was
> using the default compiler and default linker. (By the way the base-gcc
> will miscompile src/cxx_supportlib/WebSocketCommandReverseServer.h and
> either ports-clang or ports-gcc is required.)
>
> So next I manually changed all "#{cxx}" settings to
> "/usr/local/bin/clang++ -fuse-ld=lld" (similarly with "#{cc}") hoping it
> will use clang and LLD (including vendored libraries like libev and
> libuv). And then it hit another failure message saying can't create
> dynamic relocation and advise me to recompile using "-fPIC" or pass
> "-Wl,-z,notext" (sorry I lost the build log about this error, but it
> looks similar to [2] but with mips symbols). Adding only "-fPIC"
> resulted in the same error, and adding "-Wl,-z,notext" resulted in
> another fatal error included in the attached build log. I have also
> attached my modification on the ruby-passenger ports hope someone can
> give a suggestion on how to properly change compilers using rake.
>
> Any advice on what to try next is appreciated.
>
> [2] https://github.com/pytorch/pytorch/issues/21700
>
>
> diff -urN /home/xiyueden/VCS/ports/www/ruby-passenger/Makefile ./Makefile
> --- /home/xiyueden/VCS/ports/www/ruby-passenger/Makefile Tue Dec 24 05:32:30 2019
> +++ ./Makefile Fri Dec 27 20:48:52 2019
> @@ -24,7 +24,9 @@
>
> WANTLIB = ${MODRUBY_WANTLIB} crypto curl kvm nghttp2 pcre pthread ssl ${COMPILER_LIBCXX} z
>
> -COMPILER = base-clang ports-gcc base-gcc
> +# COMPILER = base-clang ports-gcc base-gcc
> +COMPILER = base-clang ports-clang ports-gcc base-gcc
> +MODCLANG_ARCHS = mips64 mips64el
>
> # Make devel/gmake a BUILD_DEPEND instead of USE_GMAKE, as the port also uses
> # BSD make. Depend on gsed as embedded libuv picks it up if present.
> @@ -42,6 +44,10 @@
> PASS_DIR = ${GEM_BASE_LIB}/gems/${DISTNAME}
>
> SUBST_VARS = MODRUBY_FLAVOR NGINX_VERSION PASS_VERSION
> +
> +.if ${MACHINE_ARCH} == "mips64" || ${MACHINE_ARCH} == "mips64el"
> +USE_LLD = Yes
> +.endif
>
> pre-configure:
> ${SUBST_CMD} -DRUBY=${RUBY} \
> diff -urN /home/xiyueden/VCS/ports/www/ruby-passenger/patches/patch-build_common_library_rb ./patches/patch-build_common_library_rb
> --- /home/xiyueden/VCS/ports/www/ruby-passenger/patches/patch-build_common_library_rb Wed Dec 31 16:00:00 1969
> +++ ./patches/patch-build_common_library_rb Mon Dec 30 04:12:09 2019
> @@ -0,0 +1,24 @@
> +--- build/common_library.rb.orig Tue Sep 17 17:11:30 2019
> ++++ build/common_library.rb Sun Dec 29 05:55:24 2019
> +@@ -129,8 +129,8 @@
> + "src/cxx_supportlib/vendor-modified/libev/Makefile.am"
> + ]
> + file LIBEV_OUTPUT_DIR + "Makefile" => dependencies do
> +- cc_command = cc
> +- cxx_command = cxx
> ++ cc_command = "/usr/local/bin/clang -fuse-ld=lld"
> ++ cxx_command = "/usr/local/bin/clang++ -fuse-ld=lld"
> + if OPTIMIZE && LTO
> + cc_command = "#{cc_command} -flto"
> + cxx_command = "#{cxx_command} -flto"
> +@@ -199,8 +199,8 @@
> + "src/cxx_supportlib/vendor-copy/libuv/Makefile.am"
> + ]
> + file LIBUV_OUTPUT_DIR + "Makefile" => dependencies do
> +- cc_command = cc
> +- cxx_command = cxx
> ++ cc_command = "/usr/local/bin/clang -fuse-ld=lld"
> ++ cxx_command = "/usr/local/bin/clang++ -fuse-ld=lld"
> + if OPTIMIZE && LTO
> + cc_command = "#{cc_command} -flto"
> + cxx_command = "#{cxx_command} -flto"
> diff -urN /home/xiyueden/VCS/ports/www/ruby-passenger/patches/patch-build_support_cplusplus_rb ./patches/patch-build_support_cplusplus_rb
> --- /home/xiyueden/VCS/ports/www/ruby-passenger/patches/patch-build_support_cplusplus_rb Wed Dec 31 16:00:00 1969
> +++ ./patches/patch-build_support_cplusplus_rb Mon Dec 30 04:11:16 2019
> @@ -0,0 +1,49 @@
> +--- build/support/cplusplus.rb.orig Tue Sep 17 17:11:30 2019
> ++++ build/support/cplusplus.rb Sun Dec 29 16:52:41 2019
> +@@ -93,29 +93,29 @@
> + end
> +
> + def compile_c(object, source, options_or_flags = nil)
> +- flags = build_compiler_flags_from_options_or_flags(options_or_flags)
> ++ flags = build_compiler_flags_from_options_or_flags(options_or_flags) + " -fPIC"
> + ensure_target_directory_exists(object)
> +- run_compiler("#{cc} -o #{object} #{EXTRA_PRE_CFLAGS} #{flags} #{extra_cflags} -c #{source}")
> ++ run_compiler("/usr/local/bin/clang -o #{object} #{EXTRA_PRE_CFLAGS} #{flags} #{extra_cflags} -c #{source}")
> + end
> +
> + def compile_cxx(object, source, options_or_flags = nil)
> +- flags = build_compiler_flags_from_options_or_flags(options_or_flags)
> ++ flags = build_compiler_flags_from_options_or_flags(options_or_flags) + " -fPIC"
> + ensure_target_directory_exists(object)
> +- run_compiler("#{cxx} -o #{object} #{EXTRA_PRE_CXXFLAGS} #{flags} #{extra_cxxflags} -c #{source}")
> ++ run_compiler("/usr/local/bin/clang++ -o #{object} #{EXTRA_PRE_CXXFLAGS} #{flags} #{extra_cxxflags} -c #{source}")
> + end
> +
> + def create_c_executable(target, objects, options_or_flags = nil)
> + objects = [objects].flatten.join(" ")
> +- flags = build_compiler_flags_from_options_or_flags(options_or_flags)
> ++ flags = build_compiler_flags_from_options_or_flags(options_or_flags) + " -fPIC -Wl,-z,notext"
> + ensure_target_directory_exists(target)
> +- run_compiler("#{cc} -o #{target} #{objects} #{EXTRA_PRE_C_LDFLAGS} #{flags} #{extra_c_ldflags}")
> ++ run_compiler("/usr/local/bin/clang -fuse-ld=lld -o #{target} #{objects} #{EXTRA_PRE_C_LDFLAGS} #{flags} #{extra_c_ldflags}")
> + end
> +
> + def create_cxx_executable(target, objects, options_or_flags = nil)
> + objects = [objects].flatten.join(" ")
> +- flags = build_compiler_flags_from_options_or_flags(options_or_flags)
> ++ flags = build_compiler_flags_from_options_or_flags(options_or_flags) + " -fPIC -Wl,-z,notext"
> + ensure_target_directory_exists(target)
> +- run_compiler("#{cxx} -o #{target} #{objects} #{EXTRA_PRE_CXX_LDFLAGS} #{flags} #{extra_cxx_ldflags}")
> ++ run_compiler("/usr/local/bin/clang++ -fuse-ld=lld -o #{target} #{objects} #{EXTRA_PRE_CXX_LDFLAGS} #{flags} #{extra_cxx_ldflags}")
> + end
> +
> + def create_static_library(target, objects)
> +@@ -144,7 +144,7 @@
> + objects = [objects].flatten.join(" ")
> + flags = build_compiler_flags_from_options_or_flags(options_or_flags)
> + ensure_target_directory_exists(target)
> +- run_compiler("#{cxx} #{shlib_flag} #{objects} #{fPIC} -o #{target} #{flags}")
> ++ run_compiler("/usr/local/bin/clang++ -v -fuse-ld=lld #{shlib_flag} #{objects} #{fPIC} -Wl,-z,notext -o #{target} #{flags}")
> + end
> +
> + def define_c_object_compilation_task(object, source, options_or_flags = nil)

No comments:

Post a Comment