From 327fe1d45c1c3d25fd5e134cab822736b16e3d3f Mon Sep 17 00:00:00 2001
From: Jan Beich <jbeich@FreeBSD.org>
Date: Sun, 29 Sep 2019 04:01:47 +0000
Subject: [PATCH] devel/llvm90: default to -march=i586 to avoid libatomic on
 i386

Required by Firefox-based ports to avoid the following:
mozglue/misc/TimeStamp.o: In function `mozilla::TimeStamp::NowFuzzy(mozilla::TimeStamp63Bit)':
TimeStamp.cpp:(.text._ZN7mozilla9TimeStamp8NowFuzzyENS_14TimeStamp63BitE+0x22): undefined reference to `__atomic_load_8'
mozglue/misc/TimeStamp.o: In function `mozilla::TimeStamp::UpdateFuzzyTimeStamp(mozilla::TimeStamp)':
TimeStamp.cpp:(.text._ZN7mozilla9TimeStamp20UpdateFuzzyTimeStampES0_+0x28): undefined reference to `__atomic_store_8'
mozglue/misc/TimeStamp.o: In function `mozilla::TimeStamp::NowFuzzyTime()':
TimeStamp.cpp:(.text._ZN7mozilla9TimeStamp12NowFuzzyTimeEv+0x1a): undefined reference to `__atomic_load_8'
mozglue/misc/TimeStamp.o: In function `mozilla::TimeStamp::UpdateFuzzyTime(long long)':
TimeStamp.cpp:(.text._ZN7mozilla9TimeStamp15UpdateFuzzyTimeEx+0x20): undefined reference to `__atomic_store_8'
clang-9: error: linker command failed with exit code 1 (use -v to see invocation)

PR:		240918
Submitted by:	dim
Approved by:	brooks (maintainer)
---
 Mk/bsd.gecko.mk                                 |  3 ---
 devel/llvm90/Makefile                           |  2 +-
 ...ols_clang_lib_Driver_ToolChains_Arch_X86.cpp | 17 +++++++++++++++++
 mail/thunderbird/Makefile                       |  2 +-
 www/cliqz/Makefile                              |  6 +-----
 www/firefox-esr/Makefile                        |  2 +-
 www/firefox/Makefile                            |  2 +-
 7 files changed, 22 insertions(+), 12 deletions(-)
 create mode 100644 devel/llvm90/files/clang/patch-tools_clang_lib_Driver_ToolChains_Arch_X86.cpp

diff --git a/Mk/bsd.gecko.mk b/Mk/bsd.gecko.mk
index 7a1417a10f38..0e25b0a497ca 100644
--- a/Mk/bsd.gecko.mk
+++ b/Mk/bsd.gecko.mk
@@ -90,9 +90,6 @@ MOZ_MK_OPTIONS+=MOZ_OBJDIR="${BUILD_WRKSRC}"
 
 # Require newer Clang than what's in base system unless user opted out
 . if ${CC} == cc && ${CXX} == c++ && exists(/usr/lib/libc++.so)
-.if ${LLVM_DEFAULT:S,-devel,990,} >= 90 && ${ARCH} == i386
-LLVM_DEFAULT=	80
-.endif
 BUILD_DEPENDS+=	${LOCALBASE}/bin/clang${LLVM_DEFAULT}:devel/llvm${LLVM_DEFAULT}
 CPP=			${LOCALBASE}/bin/clang-cpp${LLVM_DEFAULT}
 CC=				${LOCALBASE}/bin/clang${LLVM_DEFAULT}
diff --git a/devel/llvm90/Makefile b/devel/llvm90/Makefile
index dbf3f1dae4c5..c58dce2aa2c4 100644
--- a/devel/llvm90/Makefile
+++ b/devel/llvm90/Makefile
@@ -2,7 +2,7 @@
 
 PORTNAME=	llvm
 DISTVERSION=	9.0.0
-PORTREVISION=	0
+PORTREVISION=	1
 CATEGORIES=	devel lang
 .if ${DISTVERSION:M*rc*}
 MASTER_SITES=  http://prereleases.llvm.org/${LLVM_RELEASE}/${RCDIR}
diff --git a/devel/llvm90/files/clang/patch-tools_clang_lib_Driver_ToolChains_Arch_X86.cpp b/devel/llvm90/files/clang/patch-tools_clang_lib_Driver_ToolChains_Arch_X86.cpp
new file mode 100644
index 000000000000..7caa1ef45c63
--- /dev/null
+++ b/devel/llvm90/files/clang/patch-tools_clang_lib_Driver_ToolChains_Arch_X86.cpp
@@ -0,0 +1,17 @@
+https://svnweb.freebsd.org/changeset/base/352030
+
+--- tools/clang/lib/Driver/ToolChains/Arch/X86.cpp.orig	2019-07-16 22:32:17 UTC
++++ tools/clang/lib/Driver/ToolChains/Arch/X86.cpp
+@@ -93,10 +93,10 @@ const char *x86::getX86TargetCPU(const ArgList &Args,
+     return "x86-64";
+ 
+   switch (Triple.getOS()) {
+-  case llvm::Triple::FreeBSD:
+   case llvm::Triple::NetBSD:
+   case llvm::Triple::OpenBSD:
+-    return "i486";
++    return "i486"; 
++  case llvm::Triple::FreeBSD:
+   case llvm::Triple::Haiku:
+     return "i586";
+   default:
diff --git a/mail/thunderbird/Makefile b/mail/thunderbird/Makefile
index fa5e8f8046cb..1198d77fd521 100644
--- a/mail/thunderbird/Makefile
+++ b/mail/thunderbird/Makefile
@@ -3,7 +3,7 @@
 
 PORTNAME=	thunderbird
 DISTVERSION=	68.1.1
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	mail news net-im ipv6
 MASTER_SITES=	MOZILLA/${PORTNAME}/releases/${DISTVERSION}/source \
 		MOZILLA/${PORTNAME}/candidates/${DISTVERSION}-candidates/build1/source
diff --git a/www/cliqz/Makefile b/www/cliqz/Makefile
index eac45622f121..7a8c96bff025 100644
--- a/www/cliqz/Makefile
+++ b/www/cliqz/Makefile
@@ -2,6 +2,7 @@
 
 PORTNAME=	cliqz
 DISTVERSION=	1.29.0
+PORTREVISION=	1
 CATEGORIES=	www
 MASTER_SITES=	https://s3.amazonaws.com/cdn.cliqz.com/browser-f/APT/:amazon \
 		http://repository.cliqz.com/dist/${CLIQZ_CHANNEL}/${DISTVERSION}/${CLIQZ_LAST_BUILD_ID}/:cliqz
@@ -95,11 +96,6 @@ MOZ_CONFIGURE_ARGS+=	"ac_add_options --disable-crashreporter" \
 
 .include <bsd.port.pre.mk>
 
-# Default to llvm 8 for i386
-.if ${ARCH} == i386 && ${LLVM_DEFAULT:S,-devel,990,} >= 90
-LLVM_DEFAULT=	80
-.endif
-
 # Require newer Clang than what's in base system unless user opted out
 .if ${CC} == cc && ${CXX} == c++ && exists(/usr/lib/libc++.so)
 CPP=		${LOCALBASE}/bin/clang-cpp${LLVM_DEFAULT}
diff --git a/www/firefox-esr/Makefile b/www/firefox-esr/Makefile
index 77a8cce112e9..f1a4a53e67b9 100644
--- a/www/firefox-esr/Makefile
+++ b/www/firefox-esr/Makefile
@@ -3,7 +3,7 @@
 
 PORTNAME=	firefox
 DISTVERSION=	68.1.0
-PORTREVISION=	4
+PORTREVISION=	5
 PORTEPOCH=	1
 CATEGORIES=	www ipv6
 MASTER_SITES=	MOZILLA/${PORTNAME}/releases/${DISTVERSION}esr/source \
diff --git a/www/firefox/Makefile b/www/firefox/Makefile
index d443ed95cc9c..726a0434e404 100644
--- a/www/firefox/Makefile
+++ b/www/firefox/Makefile
@@ -3,7 +3,7 @@
 
 PORTNAME=	firefox
 DISTVERSION=	69.0.1
-PORTREVISION=	2
+PORTREVISION=	3
 PORTEPOCH=	1
 CATEGORIES=	www ipv6
 MASTER_SITES=	MOZILLA/${PORTNAME}/releases/${DISTVERSION}/source \