diff mbox series

[v3] package/uhd: fix usrp2 build with boost 1.77.0

Message ID 20211122135737.1784748-1-gwenj@trabucayre.com
State Accepted
Headers show
Series [v3] package/uhd: fix usrp2 build with boost 1.77.0 | expand

Commit Message

Gwenhael Goavec-Merou Nov. 22, 2021, 1:57 p.m. UTC
From: Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>

Fix build failure:
uhd-3.15.0.0/host/lib/usrp/usrp2/usrp2_impl.cpp:847:29: error: 'boost::math' has not been declared
for boost::math::sign and boost::math::iround

Backport and adapt commits:
- 3796175f32f0cc24c16809d8175d423bc7053de9
- d1c6290fe9c8b01068abfca6f272e2a1e031b9de

Fixes:
- http://autobuild.buildroot.net/results/aa2bd1fbe1b4880aa8de389238380a3d35f80b53/
- http://autobuild.buildroot.net/results/22b022f360d0f0f23161bc279b736e6a80f87c1a/
- http://autobuild.buildroot.net/results/f65ea915509a8669c624ddab85e76576c8522005/

Signed-off-by: Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
---
Changes v2 -> v3:
- fix patches
Changes v1 -> v2:
- backport the two commits in separate patches (Yann)
- add SoB and backport info (Yann)
---
 ...ost-math-iround-math-sign-with-std-l.patch | 58 +++++++++++++++++++
 ...explicit-template-type-for-std-min-T.patch | 28 +++++++++
 2 files changed, 86 insertions(+)
 create mode 100644 package/uhd/0006-usrp2-Replace-boost-math-iround-math-sign-with-std-l.patch
 create mode 100644 package/uhd/0007-usrp2-Use-explicit-template-type-for-std-min-T.patch

Comments

Arnout Vandecappelle Nov. 25, 2021, 7:46 p.m. UTC | #1
On 22/11/2021 14:57, Gwenhael Goavec-Merou wrote:
> From: Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
> 
> Fix build failure:
> uhd-3.15.0.0/host/lib/usrp/usrp2/usrp2_impl.cpp:847:29: error: 'boost::math' has not been declared
> for boost::math::sign and boost::math::iround
> 
> Backport and adapt commits:
> - 3796175f32f0cc24c16809d8175d423bc7053de9
> - d1c6290fe9c8b01068abfca6f272e2a1e031b9de
> 
> Fixes:
> - http://autobuild.buildroot.net/results/aa2bd1fbe1b4880aa8de389238380a3d35f80b53/
> - http://autobuild.buildroot.net/results/22b022f360d0f0f23161bc279b736e6a80f87c1a/
> - http://autobuild.buildroot.net/results/f65ea915509a8669c624ddab85e76576c8522005/
> 
> Signed-off-by: Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
> ---
> Changes v2 -> v3:
> - fix patches
> Changes v1 -> v2:
> - backport the two commits in separate patches (Yann)
> - add SoB and backport info (Yann)
> ---
>   ...ost-math-iround-math-sign-with-std-l.patch | 58 +++++++++++++++++++
>   ...explicit-template-type-for-std-min-T.patch | 28 +++++++++
>   2 files changed, 86 insertions(+)
>   create mode 100644 package/uhd/0006-usrp2-Replace-boost-math-iround-math-sign-with-std-l.patch
>   create mode 100644 package/uhd/0007-usrp2-Use-explicit-template-type-for-std-min-T.patch
> 
> diff --git a/package/uhd/0006-usrp2-Replace-boost-math-iround-math-sign-with-std-l.patch b/package/uhd/0006-usrp2-Replace-boost-math-iround-math-sign-with-std-l.patch
> new file mode 100644
> index 0000000000..09869da61b
> --- /dev/null
> +++ b/package/uhd/0006-usrp2-Replace-boost-math-iround-math-sign-with-std-l.patch
> @@ -0,0 +1,58 @@
> +From 3796175f32f0cc24c16809d8175d423bc7053de9 Mon Sep 17 00:00:00 2001
> +From: StefanBruens <stefan.bruens@rwth-aachen.de>
> +Date: Wed, 5 May 2021 18:24:58 +0200
> +Subject: [PATCH 003/121] usrp2: Replace boost::math::iround/math::sign with
> +std::lround

  You have a funny way of backporting patches... The 003/121 is weird 
(check-package also complains about it), and the continuation line is normally 
indented with two spaces.

  The normal way of creating patches is:

- clone the upstream repo;
- checkout the tag or hash corresponding to the buildroot version;
- git am <buildroot>/package/<package>/00*.patch
- cherry-pick the upstream commits, resolve conflicts
- git format-patch -N <tag>.. -o <buildroot>/package/<package>

  Anyway, fixed and applied to master, thanks.

  Regards,
  Arnout


> +
> +Instead of multiplying zone with the sign repeatedly just make
> +the zone a signed value.
> +
> +See #437, #438
> +
> +Signed-off-by: Aaron Rossetto <aaron.rossetto@ni.com>
> +[gwenhael.goavec-merou@trabucayre.com: backport from upstream]
> +Signed-off-by: Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
> +---
> + host/lib/usrp/usrp2/usrp2_impl.cpp | 10 +++++-----
> + 1 file changed, 5 insertions(+), 5 deletions(-)
> +
> +diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp
> +index 1be4c7339..c0719a316 100644
> +--- a/host/lib/usrp/usrp2/usrp2_impl.cpp
> ++++ b/host/lib/usrp/usrp2/usrp2_impl.cpp
> +@@ -22,6 +22,7 @@
> + #include <boost/asio/ip/address_v4.hpp>
> + #include <boost/asio.hpp> //used for htonl and ntohl
> + #include <boost/thread.hpp>
> ++#include <cmath>
> +
> + using namespace uhd;
> + using namespace uhd::usrp;
> +@@ -844,20 +845,19 @@ double usrp2_impl::set_tx_dsp_freq(
> +         _tree->access<double>("/mboards/"+mb+"/tick_rate").get();
> +
> +     //calculate the DAC shift (multiples of rate)
> +-    const int sign = boost::math::sign(new_freq);
> +-    const int zone = std::min(boost::math::iround(new_freq/tick_rate), 2);
> +-    const double dac_shift = sign*zone*tick_rate;
> ++    const int zone         = std::max(std::min(std::lround(new_freq / tick_rate), 2), -2);
> ++    const double dac_shift = zone * tick_rate;
> +     new_freq -= dac_shift; //update FPGA DSP target freq
> +     UHD_LOG_TRACE("USRP2",
> +         "DSP Tuning: Requested " + std::to_string(freq_/1e6) + " MHz, Using "
> +-        "Nyquist zone " + std::to_string(sign*zone) + ", leftover DSP tuning: "
> ++        "Nyquist zone " + std::to_string(zone) + ", leftover DSP tuning: "
> +         + std::to_string(new_freq/1e6) + " MHz.");
> +
> +     //set the DAC shift (modulation mode)
> +     if (zone == 0) {
> +         _mbc[mb].codec->set_tx_mod_mode(0); //no shift
> +     } else {
> +-        _mbc[mb].codec->set_tx_mod_mode(sign*4/zone); //DAC interp = 4
> ++        _mbc[mb].codec->set_tx_mod_mode(4 / zone); // DAC interp = 4
> +     }
> +
> +     return _mbc[mb].tx_dsp->set_freq(new_freq) + dac_shift; //actual freq
> +--
> +2.32.0
> +
> diff --git a/package/uhd/0007-usrp2-Use-explicit-template-type-for-std-min-T.patch b/package/uhd/0007-usrp2-Use-explicit-template-type-for-std-min-T.patch
> new file mode 100644
> index 0000000000..3da8370153
> --- /dev/null
> +++ b/package/uhd/0007-usrp2-Use-explicit-template-type-for-std-min-T.patch
> @@ -0,0 +1,28 @@
> +From d1c6290fe9c8b01068abfca6f272e2a1e031b9de Mon Sep 17 00:00:00 2001
> +From: StefanBruens <stefan.bruens@rwth-aachen.de>
> +Date: Wed, 5 May 2021 18:49:40 +0200
> +Subject: [PATCH 004/121] usrp2: Use explicit template type for std::min<T>
> +
> +Signed-off-by: Aaron Rossetto <aaron.rossetto@ni.com>
> +[gwenhael.goavec-merou@trabucayre.com: backport from upstream]
> +Signed-off-by: Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
> +---
> + host/lib/usrp/usrp2/usrp2_impl.cpp | 2 +-
> + 1 file changed, 1 insertion(+), 1 deletion(-)
> +
> +diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp
> +index 59fd9849c..e82a9fa71 100644
> +--- a/host/lib/usrp/usrp2/usrp2_impl.cpp
> ++++ b/host/lib/usrp/usrp2/usrp2_impl.cpp
> +@@ -845,7 +845,7 @@ double usrp2_impl::set_tx_dsp_freq(
> +         _tree->access<double>("/mboards/"+mb+"/tick_rate").get();
> +
> +     //calculate the DAC shift (multiples of rate)
> +-    const int zone         = std::max(std::min(std::lround(new_freq / tick_rate), 2), -2);
> ++    const int zone         = std::max(std::min<int>(std::lround(new_freq / tick_rate), 2), -2);
> +     const double dac_shift = zone * tick_rate;
> +     new_freq -= dac_shift; //update FPGA DSP target freq
> +     UHD_LOG_TRACE("USRP2",
> +--
> +2.32.0
> +
>
diff mbox series

Patch

diff --git a/package/uhd/0006-usrp2-Replace-boost-math-iround-math-sign-with-std-l.patch b/package/uhd/0006-usrp2-Replace-boost-math-iround-math-sign-with-std-l.patch
new file mode 100644
index 0000000000..09869da61b
--- /dev/null
+++ b/package/uhd/0006-usrp2-Replace-boost-math-iround-math-sign-with-std-l.patch
@@ -0,0 +1,58 @@ 
+From 3796175f32f0cc24c16809d8175d423bc7053de9 Mon Sep 17 00:00:00 2001
+From: StefanBruens <stefan.bruens@rwth-aachen.de>
+Date: Wed, 5 May 2021 18:24:58 +0200
+Subject: [PATCH 003/121] usrp2: Replace boost::math::iround/math::sign with
+std::lround
+
+Instead of multiplying zone with the sign repeatedly just make
+the zone a signed value.
+
+See #437, #438
+
+Signed-off-by: Aaron Rossetto <aaron.rossetto@ni.com>
+[gwenhael.goavec-merou@trabucayre.com: backport from upstream]
+Signed-off-by: Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
+---
+ host/lib/usrp/usrp2/usrp2_impl.cpp | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp
+index 1be4c7339..c0719a316 100644
+--- a/host/lib/usrp/usrp2/usrp2_impl.cpp
++++ b/host/lib/usrp/usrp2/usrp2_impl.cpp
+@@ -22,6 +22,7 @@
+ #include <boost/asio/ip/address_v4.hpp>
+ #include <boost/asio.hpp> //used for htonl and ntohl
+ #include <boost/thread.hpp>
++#include <cmath>
+ 
+ using namespace uhd;
+ using namespace uhd::usrp;
+@@ -844,20 +845,19 @@ double usrp2_impl::set_tx_dsp_freq(
+         _tree->access<double>("/mboards/"+mb+"/tick_rate").get();
+ 
+     //calculate the DAC shift (multiples of rate)
+-    const int sign = boost::math::sign(new_freq);
+-    const int zone = std::min(boost::math::iround(new_freq/tick_rate), 2);
+-    const double dac_shift = sign*zone*tick_rate;
++    const int zone         = std::max(std::min(std::lround(new_freq / tick_rate), 2), -2);
++    const double dac_shift = zone * tick_rate;
+     new_freq -= dac_shift; //update FPGA DSP target freq
+     UHD_LOG_TRACE("USRP2",
+         "DSP Tuning: Requested " + std::to_string(freq_/1e6) + " MHz, Using "
+-        "Nyquist zone " + std::to_string(sign*zone) + ", leftover DSP tuning: "
++        "Nyquist zone " + std::to_string(zone) + ", leftover DSP tuning: "
+         + std::to_string(new_freq/1e6) + " MHz.");
+ 
+     //set the DAC shift (modulation mode)
+     if (zone == 0) {
+         _mbc[mb].codec->set_tx_mod_mode(0); //no shift
+     } else {
+-        _mbc[mb].codec->set_tx_mod_mode(sign*4/zone); //DAC interp = 4
++        _mbc[mb].codec->set_tx_mod_mode(4 / zone); // DAC interp = 4
+     }
+ 
+     return _mbc[mb].tx_dsp->set_freq(new_freq) + dac_shift; //actual freq
+-- 
+2.32.0
+
diff --git a/package/uhd/0007-usrp2-Use-explicit-template-type-for-std-min-T.patch b/package/uhd/0007-usrp2-Use-explicit-template-type-for-std-min-T.patch
new file mode 100644
index 0000000000..3da8370153
--- /dev/null
+++ b/package/uhd/0007-usrp2-Use-explicit-template-type-for-std-min-T.patch
@@ -0,0 +1,28 @@ 
+From d1c6290fe9c8b01068abfca6f272e2a1e031b9de Mon Sep 17 00:00:00 2001
+From: StefanBruens <stefan.bruens@rwth-aachen.de>
+Date: Wed, 5 May 2021 18:49:40 +0200
+Subject: [PATCH 004/121] usrp2: Use explicit template type for std::min<T>
+
+Signed-off-by: Aaron Rossetto <aaron.rossetto@ni.com>
+[gwenhael.goavec-merou@trabucayre.com: backport from upstream]
+Signed-off-by: Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
+---
+ host/lib/usrp/usrp2/usrp2_impl.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp
+index 59fd9849c..e82a9fa71 100644
+--- a/host/lib/usrp/usrp2/usrp2_impl.cpp
++++ b/host/lib/usrp/usrp2/usrp2_impl.cpp
+@@ -845,7 +845,7 @@ double usrp2_impl::set_tx_dsp_freq(
+         _tree->access<double>("/mboards/"+mb+"/tick_rate").get();
+ 
+     //calculate the DAC shift (multiples of rate)
+-    const int zone         = std::max(std::min(std::lround(new_freq / tick_rate), 2), -2);
++    const int zone         = std::max(std::min<int>(std::lround(new_freq / tick_rate), 2), -2);
+     const double dac_shift = zone * tick_rate;
+     new_freq -= dac_shift; //update FPGA DSP target freq
+     UHD_LOG_TRACE("USRP2",
+-- 
+2.32.0
+