Building with Clang on FreeBSD

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Building with Clang on FreeBSD

Vedran Miletić-2
Hi,

I just noticed that 3.30.1 fails to build on FreeBSD with Clang:

[1451/1977] Compiling src/applications/model/application-packet-probe.cc
 
 

In file included from ../src/internet/model/tcp-socket-base.cc:46:
 
 

../src/internet/model/tcp-socket-base.h:509:28: error: bitwise
comparison always evaluates to false
[-Werror,-Wtautological-bitwise-compare]

       return ((tos & 0xfc) == 0x02);
 
 

               ~~~~~~~~~~~~~^~~~~~~
 
 

../src/internet/model/tcp-socket-base.h:519:28: error: bitwise
comparison always evaluates to false
[-Werror,-Wtautological-bitwise-compare]

       return ((tos & 0xfc) == 0x01);

               ~~~~~~~~~~~~~^~~~~~~
 
 

../src/internet/model/tcp-socket-base.h:529:28: error: bitwise
comparison always evaluates to false
[-Werror,-Wtautological-bitwise-compare]

       return ((tos & 0xfc) == 0x03);
 
 

               ~~~~~~~~~~~~~^~~~~~~
 
 

3 errors generated.

I'm just trying Clang on Linux.

FWIW, GCC also seems to have -Wtautological-compare, but it doesn't
produce a warning here.

Cheers,
Vedran

P.S.
I might not be as active here as I used to be, but I'm still gladly
using ns-3 in teaching computer networks.

--
Vedran Miletić
vedran.miletic.net
Reply | Threaded
Open this post in threaded view
|

Re: Building with Clang on FreeBSD

Natale Patriciello
On 07/06/20 at 12:44pm, Vedran Miletić wrote:
> Hi,
>
> I just noticed that 3.30.1 fails to build on FreeBSD with Clang:


hi Vedran,

What's the Clang version in FreeBSD?

Thanks,

Nat

Reply | Threaded
Open this post in threaded view
|

Re: Building with Clang on FreeBSD

Vedran Miletić-2
07. 06. 2020. u 15:08, Natale Patriciello je napisao/la:

> On 07/06/20 at 12:44pm, Vedran Miletić wrote:
>> Hi,
>>
>> I just noticed that 3.30.1 fails to build on FreeBSD with Clang:
>
>
> hi Vedran,
>
> What's the Clang version in FreeBSD?
>
> Thanks,
>
> Nat
>

Hi Natale,

I'm using 12.1-STABLE so it's 10.0:

% clang --version
FreeBSD clang version 10.0.0 ([hidden email]:llvm/llvm-project.git
llvmorg-10.0.0-0-gd32170dbd5b)
Target: x86_64-unknown-freebsd12.1
Thread model: posix
InstalledDir: /usr/bin

Cheers,
Vedran

--
Vedran Miletić
vedran.miletic.net
Reply | Threaded
Open this post in threaded view
|

Re: Building with Clang on FreeBSD

Tom Henderson-2
On 6/7/20 8:41 AM, Vedran Miletić wrote:

> 07. 06. 2020. u 15:08, Natale Patriciello je napisao/la:
>> On 07/06/20 at 12:44pm, Vedran Miletić wrote:
>>> Hi,
>>>
>>> I just noticed that 3.30.1 fails to build on FreeBSD with Clang:
>>
>>
>> hi Vedran,
>>
>> What's the Clang version in FreeBSD?
>>
>> Thanks,
>>
>> Nat
>>
>
> Hi Natale,
>
> I'm using 12.1-STABLE so it's 10.0:
>
> % clang --version
> FreeBSD clang version 10.0.0 ([hidden email]:llvm/llvm-project.git
> llvmorg-10.0.0-0-gd32170dbd5b)
> Target: x86_64-unknown-freebsd12.1
> Thread model: posix
> InstalledDir: /usr/bin
>

Vedran and Natale, I added a clang-10 (Fedora 32) machine to Jenkins and
plan to clean these issues up.

- tom
Reply | Threaded
Open this post in threaded view
|

Re: Building with Clang on FreeBSD

Vedran Miletić-2
07. 06. 2020. u 19:54, Tom Henderson je napisao/la:
> Vedran and Natale, I added a clang-10 (Fedora 32) machine to Jenkins and
> plan to clean these issues up.
>
> - tom

I can confirm this also happens with Clang 10.0 on Linux.

V.

--
Vedran Miletić
vedran.miletic.net
Reply | Threaded
Open this post in threaded view
|

Re: Building with Clang on FreeBSD

Tommaso Pecorella
Hi Vedran,

long time no see, and btw, I've seen what you're working - wonderful !!!


About the error... someone will have to explain it, because I feel dumb, I don't get it.

Cheers,

T.

> On 7 Jun 2020, at 20:36, Vedran Miletić <[hidden email]> wrote:
>
> 07. 06. 2020. u 19:54, Tom Henderson je napisao/la:
>> Vedran and Natale, I added a clang-10 (Fedora 32) machine to Jenkins and plan to clean these issues up.
>> - tom
>
> I can confirm this also happens with Clang 10.0 on Linux.
>
> V.
>
> --
> Vedran Miletić
> vedran.miletic.net

--------------------------------------------------------------

Who says nothing is impossible?
  Some people do it every day!
-- Alfred E. Neuman

--------------------------------------------------------------

Tommaso Pecorella - Ph.D.

Assistant professor
Dpt. Ingegneria dell'Informazione
Università di Firenze

CNIT - Università di Firenze Unit

via di S. Marta 3
50139, Firenze
ITALY

email: [hidden email]
       [hidden email]

phone : +39-055-2758540
mobile: +39-320-4379803
fax   : +39-055-2758570








Reply | Threaded
Open this post in threaded view
|

Re: Building with Clang on FreeBSD

Federico Guerra-2
*       return ((tos & 0xfc) == 0x03);*

0xfc = 0b11111100
0x01 = 0b00000001
0x02 = 0b00000010
0x03 = 0b00000011

therefore (tos & 0xfc) can never be 0x03, or 0x01 or 0x02



*Federico*

--
The information in this email is confidential and is intended solely for the

addressee(s). Access to this email by anyone else is unauthorised. If you
are not an intended recipient, you must not read, use or disseminate the
information contained in the email.

Le Informazioni contenute in questo messaggio sono confidenziali e sono
destinate al solo destinatario/i indicato/i. L'accesso di estranei a  questo
messaggio non è autorizzato. Chiunque dovesse ricevere il messaggio per
errore, non deve leggerlo, farne uso o distribuire le informazioni in esso
contenute.


On Mon, 8 Jun 2020 at 08:43, Federico Guerra <[hidden email]>
wrote:

>
>
> *       return ((tos & 0xfc) == 0x03);*
>
> 0xfc = 0b11111100
> 0x01 = 0b00000001
> 0x02 = 0b00000010
> 0x03 = 0b00000011
>
> therefore (tos & 0xfc) can never be 0x03, or 0x01 or 0x02
>
>
>
>
> *Federico*
>
> --
> The information in this email is confidential and is intended solely for
> the
> addressee(s). Access to this email by anyone else is unauthorised. If you
> are not an intended recipient, you must not read, use or disseminate the
> information contained in the email.
>
> Le Informazioni contenute in questo messaggio sono confidenziali e sono
> destinate al solo destinatario/i indicato/i. L'accesso di estranei a
>  questo
> messaggio non è autorizzato. Chiunque dovesse ricevere il messaggio per
> errore, non deve leggerlo, farne uso o distribuire le informazioni in esso
> contenute.
>
>
> On Sun, 7 Jun 2020 at 21:22, Tommaso Pecorella <[hidden email]> wrote:
>
>> Hi Vedran,
>>
>> long time no see, and btw, I've seen what you're working - wonderful !!!
>>
>>
>> About the error... someone will have to explain it, because I feel dumb,
>> I don't get it.
>>
>> Cheers,
>>
>> T.
>>
>> > On 7 Jun 2020, at 20:36, Vedran Miletić <[hidden email]> wrote:
>> >
>> > 07. 06. 2020. u 19:54, Tom Henderson je napisao/la:
>> >> Vedran and Natale, I added a clang-10 (Fedora 32) machine to Jenkins
>> and plan to clean these issues up.
>> >> - tom
>> >
>> > I can confirm this also happens with Clang 10.0 on Linux.
>> >
>> > V.
>> >
>> > --
>> > Vedran Miletić
>> > vedran.miletic.net
>>
>> --------------------------------------------------------------
>>
>> Who says nothing is impossible?
>>   Some people do it every day!
>> -- Alfred E. Neuman
>>
>> --------------------------------------------------------------
>>
>> Tommaso Pecorella - Ph.D.
>>
>> Assistant professor
>> Dpt. Ingegneria dell'Informazione
>> Università di Firenze
>>
>> CNIT - Università di Firenze Unit
>>
>> via di S. Marta 3
>> 50139, Firenze
>> ITALY
>>
>> email: [hidden email]
>>        [hidden email]
>>
>> phone : +39-055-2758540
>> mobile: +39-320-4379803
>> fax   : +39-055-2758570
>>
>>
>>
>>
>>
>>
>>
>>
>>
Reply | Threaded
Open this post in threaded view
|

Re: Building with Clang on FreeBSD

Natale Patriciello
In reply to this post by Tom Henderson-2
On 07/06/20 at 10:54am, Tom Henderson wrote:
[cut]
> Vedran and Natale, I added a clang-10 (Fedora 32) machine to Jenkins and
> plan to clean these issues up.

Thanks Tom,

I've also added Clang 10 in the Gitlab CI/CD, and indeed we have other
errors:


https://gitlab.com/nsnam/ns-3-dev/-/jobs/585355963



../src/core/model/enum.cc:150:19: error: loop variable 'i' of type 'const std::pair<int, std::__cxx11::basic_string<char> >' creates a copy from type 'const std::pair<int, std::__cxx11::basic_string<char> >' [-Werror,-Wrange-loop-construct]
  for (const auto i : m_valueSet)
                  ^
../src/core/model/enum.cc:150:8: note: use reference type 'const std::pair<int, std::__cxx11::basic_string<char> > &' to prevent copying
  for (const auto i : m_valueSet)
       ^~~~~~~~~~~~~~
                  &



PS: Thanks to the clang dev, now the compiler will refuse to compile
badly written code.. we should all move to clang :)


Nat
Reply | Threaded
Open this post in threaded view
|

Re: Building with Clang on FreeBSD

Tommaso Pecorella
In reply to this post by Federico Guerra-2
Hi Federico,

I'm blind... I should have checked what's 0xfc.

Anyway, I guess there's a bug in the code if these functions are always returning false.

T.


> On 8 Jun 2020, at 08:47, Federico Guerra <[hidden email]> wrote:
>
> *       return ((tos & 0xfc) == 0x03);*
>
> 0xfc = 0b11111100
> 0x01 = 0b00000001
> 0x02 = 0b00000010
> 0x03 = 0b00000011
>
> therefore (tos & 0xfc) can never be 0x03, or 0x01 or 0x02
>
>
>
> *Federico*
>
> --
> The information in this email is confidential and is intended solely for the
>
> addressee(s). Access to this email by anyone else is unauthorised. If you
> are not an intended recipient, you must not read, use or disseminate the
> information contained in the email.
>
> Le Informazioni contenute in questo messaggio sono confidenziali e sono
> destinate al solo destinatario/i indicato/i. L'accesso di estranei a  questo
> messaggio non è autorizzato. Chiunque dovesse ricevere il messaggio per
> errore, non deve leggerlo, farne uso o distribuire le informazioni in esso
> contenute.
>
>
> On Mon, 8 Jun 2020 at 08:43, Federico Guerra <[hidden email]>
> wrote:
>
>>
>>
>> *       return ((tos & 0xfc) == 0x03);*
>>
>> 0xfc = 0b11111100
>> 0x01 = 0b00000001
>> 0x02 = 0b00000010
>> 0x03 = 0b00000011
>>
>> therefore (tos & 0xfc) can never be 0x03, or 0x01 or 0x02
>>
>>
>>
>>
>> *Federico*
>>
>> --
>> The information in this email is confidential and is intended solely for
>> the
>> addressee(s). Access to this email by anyone else is unauthorised. If you
>> are not an intended recipient, you must not read, use or disseminate the
>> information contained in the email.
>>
>> Le Informazioni contenute in questo messaggio sono confidenziali e sono
>> destinate al solo destinatario/i indicato/i. L'accesso di estranei a
>> questo
>> messaggio non è autorizzato. Chiunque dovesse ricevere il messaggio per
>> errore, non deve leggerlo, farne uso o distribuire le informazioni in esso
>> contenute.
>>
>>
>> On Sun, 7 Jun 2020 at 21:22, Tommaso Pecorella <[hidden email]> wrote:
>>
>>> Hi Vedran,
>>>
>>> long time no see, and btw, I've seen what you're working - wonderful !!!
>>>
>>>
>>> About the error... someone will have to explain it, because I feel dumb,
>>> I don't get it.
>>>
>>> Cheers,
>>>
>>> T.
>>>
>>>> On 7 Jun 2020, at 20:36, Vedran Miletić <[hidden email]> wrote:
>>>>
>>>> 07. 06. 2020. u 19:54, Tom Henderson je napisao/la:
>>>>> Vedran and Natale, I added a clang-10 (Fedora 32) machine to Jenkins
>>> and plan to clean these issues up.
>>>>> - tom
>>>>
>>>> I can confirm this also happens with Clang 10.0 on Linux.
>>>>
>>>> V.
>>>>
>>>> --
>>>> Vedran Miletić
>>>> vedran.miletic.net
>>>
>>> --------------------------------------------------------------
>>>
>>> Who says nothing is impossible?
>>>  Some people do it every day!
>>> -- Alfred E. Neuman
>>>
>>> --------------------------------------------------------------
>>>
>>> Tommaso Pecorella - Ph.D.
>>>
>>> Assistant professor
>>> Dpt. Ingegneria dell'Informazione
>>> Università di Firenze
>>>
>>> CNIT - Università di Firenze Unit
>>>
>>> via di S. Marta 3
>>> 50139, Firenze
>>> ITALY
>>>
>>> email: [hidden email]
>>>       [hidden email]
>>>
>>> phone : +39-055-2758540
>>> mobile: +39-320-4379803
>>> fax   : +39-055-2758570
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>

--------------------------------------------------------------

``... anyone can do any amount of work, provided it isn't the
  work he is supposed to be doing at that moment.''
-- Robert Benchley, in Chips off the Old Benchley, 1949

--------------------------------------------------------------

Tommaso Pecorella - Ph.D.

Assistant professor
Dpt. Ingegneria dell'Informazione
Università di Firenze

CNIT - Università di Firenze Unit

via di S. Marta 3
50139, Firenze
ITALY

email: [hidden email]
       [hidden email]

phone : +39-055-2758540
mobile: +39-320-4379803
fax   : +39-055-2758570










Reply | Threaded
Open this post in threaded view
|

Re: Building with Clang on FreeBSD

Tom Henderson-2
On 6/8/20 11:49 AM, Tommaso Pecorella wrote:
> Hi Federico,
>
> I'm blind... I should have checked what's 0xfc.
>
> Anyway, I guess there's a bug in the code if these functions are always returning false.
>
> T.
>
Today, I will push fixes for this and other issues reported by clang.  
I have a clean build now.

- Tom

Reply | Threaded
Open this post in threaded view
|

Re: Building with Clang on FreeBSD

Tommaso Pecorella
https://gitlab.com/nsnam/ns-3-dev/-/issues/222 <https://gitlab.com/nsnam/ns-3-dev/-/issues/222>

There's another one about a loop with an auto that is missing a reference. Easy to fix.

T.


> On 8 Jun 2020, at 20:52, Tom Henderson <[hidden email]> wrote:
>
> On 6/8/20 11:49 AM, Tommaso Pecorella wrote:
>> Hi Federico,
>>
>> I'm blind... I should have checked what's 0xfc.
>>
>> Anyway, I guess there's a bug in the code if these functions are always returning false.
>>
>> T.
>>
> Today, I will push fixes for this and other issues reported by clang.   I have a clean build now.
>
> - Tom
>

--------------------------------------------------------------

With sufficient thrust, pigs fly just fine. However, this is
not necessarily a good idea. It is hard to be sure where they
are going to land, and it could be dangerous sitting under them
as they fly overhead.
-- R. Callon, RFC 1925

--------------------------------------------------------------

Tommaso Pecorella - Ph.D.

Assistant professor
Dpt. Ingegneria dell'Informazione
Università di Firenze

CNIT - Università di Firenze Unit

via di S. Marta 3
50139, Firenze
ITALY

email: [hidden email]
       [hidden email]

phone : +39-055-2758540
mobile: +39-320-4379803
fax   : +39-055-2758570