diff --git a/configure.ac b/configure.ac
index 4d739c2..e8d89a5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -13,16 +13,28 @@ AC_MSG_CHECKING([for build system compiler])
 if test "$cross_compiling" = yes; then
 	CC_FOR_BUILD=${CC_FOR_BUILD-cc}
 else
 	CC_FOR_BUILD=${CC}
 fi
 AC_MSG_RESULT(${CC_FOR_BUILD})
 AC_SUBST(CC_FOR_BUILD)
 
+AC_MSG_CHECKING([for __attribute__((__alias__()))])
+dash_cv_have_attribute_alias=no
+AC_LINK_IFELSE([AC_LANG_PROGRAM([void t() {}
+                                 void a() __attribute__((__alias__("t")));],
+                                [a();])],
+               [dash_cv_have_attribute_alias=yes])
+AC_MSG_RESULT($dash_cv_have_attribute_alias)
+if test "x$dash_cv_have_attribute_alias" = xyes; then
+  AC_DEFINE([HAVE_ALIAS_ATTRIBUTE], 1,
+            [Define if __attribute__((__alias__())) is supported])
+fi
+
 AC_ARG_ENABLE(static, AS_HELP_STRING(--enable-static, \
 				     [Build statical linked program]))
 if test "$enable_static" = "yes"; then
 	export LDFLAGS="-static -Wl,--fatal-warnings"
 fi
 
 AC_ARG_ENABLE(fnmatch, AS_HELP_STRING(--enable-fnmatch, \
 				      [Use fnmatch(3) from libc]))
@@ -54,16 +66,19 @@ if test "$ac_cv_func_signal" != yes; then
 				 [klibc has bsd_signal instead of signal])])
 fi
 
 dnl Check for stat64 (dietlibc/klibc).
 AC_CHECK_FUNC(stat64,, [
 	AC_DEFINE(fstat64, fstat, [64-bit operations are the same as 32-bit])
 	AC_DEFINE(lstat64, lstat, [64-bit operations are the same as 32-bit])
 	AC_DEFINE(stat64, stat, [64-bit operations are the same as 32-bit])
+])
+
+AC_CHECK_FUNC(open64,, [
 	AC_DEFINE(open64, open, [64-bit operations are the same as 32-bit])
 ])
 
 AC_ARG_WITH(libedit, AS_HELP_STRING(--with-libedit, [Compile with libedit support]))
 use_libedit=
 if test "$with_libedit" = "yes"; then
 	AC_CHECK_LIB(edit, history_init, [
 		AC_CHECK_HEADER([histedit.h], [use_libedit="yes"],
diff --git a/src/cd.c b/src/cd.c
index 624801d..3770664 100644
--- a/src/cd.c
+++ b/src/cd.c
@@ -253,17 +253,17 @@ getpwd()
 #ifdef __GLIBC__
 	char *dir = getcwd(0, 0);
 
 	if (dir)
 		return dir;
 #else
 	char buf[PATH_MAX];
 
-	if (getcwd(buf, sizeof(buf))
+	if (getcwd(buf, sizeof(buf)))
 		return savestr(buf);
 #endif
 
 	sh_warnx("getcwd() failed: %s", strerror(errno));
 	return nullstr;
 }
 
 int
diff --git a/src/eval.c b/src/eval.c
index 77291b4..c7d5b14 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -321,17 +321,26 @@ exexit:
 		exraise(EXEXIT);
 	}
 }
 
 
 #if !defined(__alpha__) || (defined(__GNUC__) && __GNUC__ >= 3)
 STATIC
 #endif
-void evaltreenr(union node *, int) __attribute__ ((alias("evaltree")));
+void evaltreenr(union node *n, int flags)
+#ifdef HAVE_ATTRIBUTE_ALIAS
+__attribute__ ((alias("evaltree")));
+#else
+{
+  evaltree(n, flags);
+  exraise(EXERROR);
+  /* NOTREACHED */
+}
+#endif
 
 
 STATIC void
 evalloop(union node *n, int flags)
 {
 	int status;
 
 	loopnest++;
diff --git a/src/jobs.c b/src/jobs.c
index 40dc8f6..e1a4fcf 100644
--- a/src/jobs.c
+++ b/src/jobs.c
@@ -356,17 +356,24 @@ fgcmd(int argc, char **argv)
 		}
 		outstr(jp->ps->cmd, out);
 		showpipe(jp, out);
 		retval = restartjob(jp, mode);
 	} while (*argv && *++argv);
 	return retval;
 }
 
-int bgcmd(int, char **) __attribute__((__alias__("fgcmd")));
+int bgcmd(int argc, char **argv)
+#ifdef HAVE_ALIAS_ATTRIBUTE
+__attribute__((__alias__("fgcmd")));
+#else
+{
+  return fgcmd(argc, argv);
+}
+#endif
 
 
 STATIC int
 restartjob(struct job *jp, int mode)
 {
 	struct procstat *ps;
 	int i;
 	int status;
diff --git a/src/mkbuiltins b/src/mkbuiltins
index 960c61c..3376031 100644
--- a/src/mkbuiltins
+++ b/src/mkbuiltins
@@ -32,17 +32,17 @@
 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 #
 #	@(#)mkbuiltins	8.2 (Berkeley) 5/4/95
 
 tempfile=tempfile
 if ! type tempfile > /dev/null 2>&1; then
-	tempfile=mktemp
+	tempfile="mktemp -t tempfile.XXXXXX"
 fi
 
 trap 'rm -f $temp $temp2' EXIT
 temp=$($tempfile)
 temp2=$($tempfile)
 
 builtins=$1
 
