diff options
-rwxr-xr-x | kerl | 216 |
1 files changed, 212 insertions, 4 deletions
@@ -373,6 +373,17 @@ get_otp_version() echo $1 | sed $SED_OPT -e 's/R?([0-9]{1,2})[.AB]?[-.0-9rc]*/\1/' } +get_perl_version() +{ + perl -v | grep version | sed $SED_OPT -e 's/.*v5\.([0-9]+)\.[0-9].*/\1/' +} + +get_javac_version() +{ + javaout=$(javac -version 2>&1) + echo "$javaout" | cut -d' ' -f2 | cut -d'.' -f2 +} + show_logfile() { echo "$1" @@ -381,6 +392,68 @@ show_logfile() echo "Please see $2 for full details." } +maybe_patch() +{ + # $1 = OS platform e.g., Darwin, etc + # $2 = OTP release + + release=$(get_otp_version "$2") + case "$1" in + Darwin) + maybe_patch_darwin "$release" + ;; + SunOS) + maybe_patch_sunos "$release" + ;; + *) + ;; + esac + + maybe_patch_all "$release" +} + +maybe_patch_all() +{ + perlver=$(get_perl_version) + if [ "$perlver" -ge 24 ]; then + case "$1" in + 14) + apply_r14_beam_makeops_patch >> "$LOGFILE" + ;; + 15) + apply_r15_beam_makeops_patch >> "$LOGFILE" + ;; + *) + ;; + esac + fi + + # Are we building docs? + if [ -n "$KERL_BUILD_DOCS" ]; then + if [ "$1" -le 16 ]; then + javaver=$(get_javac_version) + if [ "$javaver" -ge 8 ]; then + apply_javadoc_linting_patch >> "$LOGFILE" + fi + fi + fi +} + +maybe_patch_darwin() +{ + if [ "$1" -le 14 ]; then + CFLAGS="-DERTS_DO_INCL_GLB_INLINE_FUNC_DEF" + apply_darwin_compiler_patch >> "$LOGFILE" + fi +} + +maybe_patch_sunos() +{ + if [ "$1" -le 14 ]; then + apply_solaris_networking_patch >> "$LOGFILE" + fi +} + do_normal_build() { assert_valid_release "$1" @@ -446,11 +519,16 @@ _do_build() ERL_TOP="$KERL_BUILD_DIR/$2/otp_src_$1" cd "$ERL_TOP" || exit 1 LOGFILE="$KERL_BUILD_DIR/$2/otp_build_$1.log" + # Don't apply patches to "custom" git builds. We have no idea if they will apply + # cleanly or not. + if [ "$1" != "git" ]; then + maybe_patch "$KERL_SYSTEM" "$1" + fi if [ -n "$KERL_USE_AUTOCONF" ]; then - ./otp_build autoconf $KERL_CONFIGURE_OPTIONS > "$LOGFILE" 2>&1 && \ - ./otp_build configure $KERL_CONFIGURE_OPTIONS >> "$LOGFILE" 2>&1 + ./otp_build autoconf $KERL_CONFIGURE_OPTIONS >> "$LOGFILE" 2>&1 && \ + CFLAGS="$CFLAGS" ./otp_build configure $KERL_CONFIGURE_OPTIONS >> "$LOGFILE" 2>&1 else - ./otp_build configure $KERL_CONFIGURE_OPTIONS > "$LOGFILE" 2>&1 + CFLAGS="$CFLAGS" ./otp_build configure $KERL_CONFIGURE_OPTIONS >> "$LOGFILE" 2>&1 fi if [ $? -ne 0 ]; then @@ -482,7 +560,7 @@ _do_build() fi done fi - ./otp_build boot -a $KERL_CONFIGURE_OPTIONS > "$LOGFILE" 2>&1 + CFLAGS="$CFLAGS" ./otp_build boot -a $KERL_CONFIGURE_OPTIONS >> "$LOGFILE" 2>&1 if [ $? -ne 0 ]; then show_logfile "Build failed." "$LOGFILE" list_remove builds "$1 $2" @@ -1009,6 +1087,136 @@ tarball_download() echo "Checksum verified ($SUM)" } +apply_solaris_networking_patch() +{ + patch -p1 <<_END_PATCH +--- otp-a/erts/emulator/drivers/common/inet_drv.c ++++ otp-b/erts/emulator/drivers/common/inet_drv.c +@@ -4166,16 +4166,7 @@ + break; + + case INET_IFOPT_HWADDR: { +-#ifdef SIOCGIFHWADDR +- if (ioctl(desc->s, SIOCGIFHWADDR, (char *)&ifreq) < 0) +- break; +- buf_check(sptr, s_end, 1+2+IFHWADDRLEN); +- *sptr++ = INET_IFOPT_HWADDR; +- put_int16(IFHWADDRLEN, sptr); sptr += 2; +- /* raw memcpy (fix include autoconf later) */ +- sys_memcpy(sptr, (char*)(&ifreq.ifr_hwaddr.sa_data), IFHWADDRLEN); +- sptr += IFHWADDRLEN; +-#elif defined(SIOCGENADDR) ++#if defined(SIOCGENADDR) + if (ioctl(desc->s, SIOCGENADDR, (char *)&ifreq) < 0) + break; + buf_check(sptr, s_end, 1+2+sizeof(ifreq.ifr_enaddr)); +_END_PATCH +} + +apply_darwin_compiler_patch() +{ + patch -p0 <<_END_PATCH +--- erts/emulator/beam/beam_bp.c.orig 2011-10-03 13:12:07.000000000 -0500 ++++ erts/emulator/beam/beam_bp.c 2013-10-04 13:42:03.000000000 -0500 +@@ -496,7 +496,8 @@ + } + + /* bp_hash */ +-ERTS_INLINE Uint bp_sched2ix() { ++#ifndef ERTS_DO_INCL_GLB_INLINE_FUNC_DEF ++ERTS_GLB_INLINE Uint bp_sched2ix() { + #ifdef ERTS_SMP + ErtsSchedulerData *esdp; + esdp = erts_get_scheduler_data(); +@@ -505,6 +506,7 @@ + return 0; + #endif + } ++#endif + static void bp_hash_init(bp_time_hash_t *hash, Uint n) { + Uint size = sizeof(bp_data_time_item_t)*n; + Uint i; +--- erts/emulator/beam/beam_bp.h.orig 2011-10-03 13:12:07.000000000 -0500 ++++ erts/emulator/beam/beam_bp.h 2013-10-04 13:42:08.000000000 -0500 +@@ -144,7 +144,19 @@ + #define ErtsSmpBPUnlock(BDC) + #endif + +-ERTS_INLINE Uint bp_sched2ix(void); ++ERTS_GLB_INLINE Uint bp_sched2ix(void); ++ ++#ifdef ERTS_DO_INCL_GLB_INLINE_FUNC_DEF ++ERTS_GLB_INLINE Uint bp_sched2ix() { ++#ifdef ERTS_SMP ++ ErtsSchedulerData *esdp; ++ esdp = erts_get_scheduler_data(); ++ return esdp->no - 1; ++#else ++ return 0; ++#endif ++} ++#endif + + #ifdef ERTS_SMP + #define bp_sched2ix_proc(p) ((p)->scheduler_data->no - 1) +_END_PATCH +} + +# javadoc 8 includes always-enabled document linting which causes +# documentation builds to fail on older OTP releases. +apply_javadoc_linting_patch() +{ + # The _END_PATCH token is quoted below to disable parameter substitution + patch -p0 <<'_END_PATCH' +--- lib/jinterface/doc/src/Makefile.orig 2016-05-23 14:34:48.000000000 -0500 ++++ lib/jinterface/doc/src/Makefile 2016-05-23 14:35:48.000000000 -0500 +@@ -142,7 +142,7 @@ + rm -f errs core *~ + + jdoc:$(JAVA_SRC_FILES) +- (cd ../../java_src;$(JAVADOC) -sourcepath . -d $(JAVADOC_DEST) \ ++ (cd ../../java_src;$(JAVADOC) -Xdoclint:none -sourcepath . -d $(JAVADOC_DEST) \ + -windowtitle $(JAVADOC_TITLE) $(JAVADOC_PKGS)) + + man: +_END_PATCH +} + +# perl 5.24 fatalizes the warning this causes +apply_r14_beam_makeops_patch() +{ + patch -p0 <<'_END_PATCH' +--- erts/emulator/utils/beam_makeops.orig 2016-05-23 21:40:42.000000000 -0500 ++++ erts/emulator/utils/beam_makeops 2016-05-23 21:41:08.000000000 -0500 +@@ -1576,7 +1576,7 @@ + if $min_window{$key} > $min_window; + + pop(@{$gen_transform{$key}}) +- if defined @{$gen_transform{$key}}; # Fail ++ if defined $gen_transform{$key}; # Fail + my(@prefix) = (&make_op($comment), &make_op('', 'try_me_else', &tr_code_len(@code))); + unshift(@code, @prefix); + push(@{$gen_transform{$key}}, @code, &make_op('', 'fail')); +_END_PATCH +} + +# https://github.com/erlang/otp/commit/21ca6d3a137034f19862db769a5b7f1c5528dbc4.diff +apply_r15_beam_makeops_patch() +{ + patch -p1 <<'_END_PATCH' +--- a/erts/emulator/utils/beam_makeops ++++ b/erts/emulator/utils/beam_makeops +@@ -1711,7 +1711,7 @@ sub tr_gen_to { + my $prev_last; + $prev_last = pop(@{$gen_transform{$key}}) +- if defined @{$gen_transform{$key}}; # Fail ++ if defined $gen_transform{$key}; # Fail + + if ($prev_last && !is_instr($prev_last, 'fail')) { + error("Line $line: A previous transformation shadows '$orig_transform'"); +_END_PATCH +} + case "$1" in version) echo "$KERL_VERSION" |