using clang to compile squid 4-5

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

using clang to compile squid 4-5

graf huy
Hi,

The purpose is to compile squid to get HTTPS or SSL with bump support, on Debian 10 (Buster).

After trying to compile squid-4-5  with clang (clang version 7.0.1-4 (tags/RELEASE_701/final)), it doesn't work.

Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64

The command ./configure is followed by the options:

--enable-ssl --enable-ssl-crtd --localstatedir=/var --datadir=/usr/share/squid --sysconfdir=/etc/squid --libexecdir=/usr/lib/squid --mandir=/usr/share/man --enable-inline --disable-arch-native --enable-async-io=8  --enable-storeio="ufs,aufs,diskd,rock" --enable-removal-policies="lru,heap" --enable-delay-pools --enable-cache-digests --enable-icap-client --enable-follow-x-forwarded-for --enable-auth-basic="DB,fake,getpwnam,LDAP,NCSA,NIS,PAM,POP3,RADIUS,SASL,SMB" --enable-auth-digest="file,LDAP" --enable-auth-negotiate="kerberos,wrapper" --enable-auth-ntlm="fake,SMB_LM" --enable-external-acl-helpers="file_userip,kerberos_ldap_group,LDAP_group,session,SQL_session,time_quota,unix_group,wbinfo_group" --enable-security-cert-validators="fake" --enable-storeid-rewrite-helpers="file" --enable-url-rewrite-helpers="fake" --enable-eui  --enable-esi --enable-icmp --enable-zph-qos --enable-ecap --disable-translation --with-swapdir=/var/spool/squid --with-logdir=/var/log/squid --with-pidfile=/var/run/squid.pid --with-filedescriptors=65536 --with-large-files --with-default-user=proxy --with-gnutls --with-openssl

The option --with-openssl is added because the output of ./configure ...  says to add it for ssl support.

The Makefile is modified so each line with gcc is replaced with clang and each line of g++ replaced with clang++. But gcc is still used.

Some of these:

CC = clang

CCDEPMODE = depmode=gcc3

CFLAGS = -m64 -Wall -g -O2

CGIEXT = .cgi

CHMOD = /bin/chmod

CPP = clang -E

CPPFLAGS = -I/usr/include/libxml2

CRYPTLIB = -lcrypt

CXX = clang++

CXXCPP = clang++ -E

CXXDEPMODE = depmode=gcc3

CXXFLAGS = -m64 -I/usr/include/p11-kit-1 -g -O2



I'm doing something wrong, but don't see where.

Thanks in advance for any help.


_______________________________________________
squid-users mailing list
[hidden email]
http://lists.squid-cache.org/listinfo/squid-users
Reply | Threaded
Open this post in threaded view
|

Re: using clang to compile squid 4-5

Alex Rousskov
On 1/22/19 6:21 AM, graf huy wrote:

> The Makefile is modified so each line with gcc is replaced with clang
> and each line of g++ replaced with clang++. But gcc is still used.

I am not sure you are doing that, but, just in case, you should not be
modifying Makefiles (or any other files generated by ./configure)
manually. You should convince ./configure to select clang instead.

I suggest using update-alternatives(1) to switch between gcc and clang
compilers (or between gcc versions). It may be a bit difficult to get
working initially, but works well once you figure out the right
commands. Please note that you should be switching both C and C++
compilers at the same time (i.e., both should come from either GCC or
clang). Search the web for more detailed instructions -- your "how to
switch from gcc to clang on Debian 10" question/problem is not specific
to Squid.

If you are using update-alternatives already, you may want to share your
commands, their output, and the corresponding ./configure output.

Alex.
_______________________________________________
squid-users mailing list
[hidden email]
http://lists.squid-cache.org/listinfo/squid-users
Reply | Threaded
Open this post in threaded view
|

Re: using clang to compile squid 4-5

Amos Jeffries
Administrator
On 23/01/19 5:17 am, Alex Rousskov wrote:
> On 1/22/19 6:21 AM, graf huy wrote:
>
>> The Makefile is modified so each line with gcc is replaced with clang
>> and each line of g++ replaced with clang++. But gcc is still used.
>
> I am not sure you are doing that,

Seconded. With both my Squid Project and Debian pkg-squid Team hat's on
I'd like to know why you feel any need to force the compiler?


Amos
_______________________________________________
squid-users mailing list
[hidden email]
http://lists.squid-cache.org/listinfo/squid-users
Reply | Threaded
Open this post in threaded view
|

Re: using clang to compile squid 4-5

graf huy
Hi,

Using update-alternatives to set clang++ was a success, and export CC=/usr/bin/clang does the job (trying two differents methods). Debian project recommended to use export (CC,CCX) for versioning and only update-alternatives for alternative as it says.
Anyway compilation with clang was as quick as gcc can do.

/usr/local/squid/sbin# ./squid -v
Squid Cache: Version 4.5
Service Name: squid

This binary uses OpenSSL 1.1.1a  20 Nov 2018. For legal restrictions on distribution see https://www.openssl.org/source/license.html

configure options:  '--enable-ssl' '--enable-ssl-crtd' '--localstatedir=/var' '--datadir=/usr/share/squid' '--sysconfdir=/etc/squid' '--libexecdir=/usr/lib/squid' '--mandir=/usr/share/man' '--enable-inline' '--disable-arch-native' '--enable-async-io=8' '--enable-storeio=ufs,aufs,diskd,rock' '--enable-removal-policies=lru,heap' '--enable-delay-pools' '--enable-cache-digests' '--enable-icap-client' '--enable-follow-x-forwarded-for' '--enable-auth-basic=DB,fake,getpwnam,LDAP,NCSA,NIS,PAM,POP3,RADIUS,SASL,SMB' '--enable-auth-digest=file,LDAP' '--enable-auth-negotiate=kerberos,wrapper' '--enable-auth-ntlm=fake,SMB_LM' '--enable-external-acl-helpers=file_userip,kerberos_ldap_group,LDAP_group,session,SQL_session,time_quota,unix_group,wbinfo_group' '--enable-security-cert-validators=fake' '--enable-storeid-rewrite-helpers=file' '--enable-url-rewrite-helpers=fake' '--enable-eui' '--enable-esi' '--enable-icmp' '--enable-zph-qos' '--enable-ecap' '--disable-translation' '--with-swapdir=/var/spool/squid' '--with-logdir=/var/log/squid' '--with-pidfile=/var/run/squid.pid' '--with-filedescriptors=65536' '--with-large-files' '--with-default-user=proxy' '--with-gnutls' '--with-openssl' 'CC=/usr/bin/clang'



>Seconded. With both my Squid Project and Debian pkg-squid Team hat's on
>I'd like to know why you feel any need to force the compiler?

There were errors to patch with memcpy because of the gcc version  8.2.0-14 Debian wich considers some warnings as errors, besides some targets are BSD's.

smblib-util.c: In function ‘SMB_Negotiate’:
smblib-util.c:404:9: error: ‘strncpy’ output may be truncated copying 79 bytes from a string of length 79 [-Werror=stringop-truncation]
         strncpy(p, Con_Handle -> Svr_PDom, sizeof(Con_Handle -> Svr_PDom) - 1);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
smblib-util.c:427:9: error: ‘strncpy’ output may be truncated copying 79 bytes from a string of length 79 [-Werror=stringop-truncation]
         strncpy(p, Con_Handle -> Svr_PDom, sizeof(Con_Handle -> Svr_PDom) - 1);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
smblib-util.c: In function ‘SMB_TreeConnect’:
smblib-util.c:541:5: error: ‘strncpy’ specified bound 129 equals destination size [-Werror=stringop-truncation]
     strncpy(tree -> path, path, sizeof(tree -> path));
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
smblib-util.c:542:5: error: ‘strncpy’ specified bound 20 equals destination size [-Werror=stringop-truncation]
     strncpy(tree -> device_type, device, sizeof(tree -> device_type));
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Although my heart bleeds to use a compiler not compliant with GPL on Debian.

Great to known you are on this package, I thought there was only Luigi Gangitano ([hidden email]) for ages...


Best regards.


Le mercredi 23 janvier 2019 à 05:25:04 UTC+1, Amos Jeffries <[hidden email]> a écrit :


On 23/01/19 5:17 am, Alex Rousskov wrote:
> On 1/22/19 6:21 AM, graf huy wrote:
>
>> The Makefile is modified so each line with gcc is replaced with clang
>> and each line of g++ replaced with clang++. But gcc is still used.
>
> I am not sure you are doing that,

Seconded. With both my Squid Project and Debian pkg-squid Team hat's on
I'd like to know why you feel any need to force the compiler?


Amos

_______________________________________________
squid-users mailing list
[hidden email]
http://lists.squid-cache.org/listinfo/squid-users

_______________________________________________
squid-users mailing list
[hidden email]
http://lists.squid-cache.org/listinfo/squid-users
Reply | Threaded
Open this post in threaded view
|

Re: using clang to compile squid 4-5

Amos Jeffries
Administrator
On 30/01/19 9:38 pm, graf huy wrote:
> Hi,
>
> Using update-alternatives to set clang++ was a success, and export
> CC=/usr/bin/clang does the job (trying two differents methods). Debian
> project recommended to use export (CC,CCX) for versioning and only
> update-alternatives for alternative as it says.
> Anyway compilation with clang was as quick as gcc can do.
>

Great to know. Nothing to fix on that front for us then.

>
>>Seconded. With both my Squid Project and Debian pkg-squid Team hat's on
>>I'd like to know why you feel any need to force the compiler?
>
> There were errors to patch with memcpy because of the gcc version 
> 8.2.0-14 Debian wich considers some warnings as errors, besides some
> targets are BSD's.
>

I'm not sure I follow that. Are you building with patched GCC? or a
patched libc? or something else?

I build with the Debian Sid GCC version myself and have not seen these
in any test builds with that or similar GCC versions. Am trying your
build options now just to be sure.


On the matter of BSD's, since they provide clang as the default compiler
they (FreeBSD at least) build with clan/clang++ without any need for
CC/CXX setting. We have Jenkins tests for that.


>
> Great to known you are on this package, I thought there was only Luigi
> Gangitano ([hidden email]) for ages...
>

Welcome. There are several of us, with Luigi as team lead.

Amos
_______________________________________________
squid-users mailing list
[hidden email]
http://lists.squid-cache.org/listinfo/squid-users
Reply | Threaded
Open this post in threaded view
|

Re: using clang to compile squid 4-5

L.P.H. van Belle
Hai,

Good to hear there are more then Luigi :-)

I builded debian packages yesterday for squid 4.5
Which was pretty simple and worked fine in the end.

Get the source of 4.4  ( apt-get source -t unstable squid  )
Copy the debian folder from 4.4 into the 4.5 folder.

And changed in the changelog the squid version, builded fine.
Test build failed, my change was.

diff squid-4.4/debian/rules squid-4.5/debian/rules
22c22
< DEB_INSTALL_DOCS_squid-common := debian/copyright CONTRIBUTORS CREDITS QUICKSTART RELEASENOTES.html SPONSORS
---
> DEB_INSTALL_DOCS_squid-common := debian/copyright CONTRIBUTORS CREDITS QUICKSTART SPONSORS

4.5 was missing : RELEASENOTES.html
Uhm must say, i builded the "squid-4.5-20190128-r568e66b7c" version.

Working now on a backport for debian stretch.

Thank for all the good work Amos. ( and Luigi ) !

@Amos, any chance to upload 4.5 to unstable or experimental?
I was hoping that 4.5 would get into buster, im guessing thats not going to happen?


Greetz,

Louis





> -----Oorspronkelijk bericht-----
> Van: squid-users
> [mailto:[hidden email]] Namens
> Amos Jeffries
> Verzonden: woensdag 30 januari 2019 14:08
> Aan: graf huy; [hidden email]
> Onderwerp: Re: [squid-users] using clang to compile squid 4-5
>
> On 30/01/19 9:38 pm, graf huy wrote:
> > Hi,
> >
> > Using update-alternatives to set clang++ was a success, and export
> > CC=/usr/bin/clang does the job (trying two differents
> methods). Debian
> > project recommended to use export (CC,CCX) for versioning and only
> > update-alternatives for alternative as it says.
> > Anyway compilation with clang was as quick as gcc can do.
> >
>
> Great to know. Nothing to fix on that front for us then.
>
> >
> >>Seconded. With both my Squid Project and Debian pkg-squid
> Team hat's on
> >>I'd like to know why you feel any need to force the compiler?
> >
> > There were errors to patch with memcpy because of the gcc version 
> > 8.2.0-14 Debian wich considers some warnings as errors, besides some
> > targets are BSD's.
> >
>
> I'm not sure I follow that. Are you building with patched GCC? or a
> patched libc? or something else?
>
> I build with the Debian Sid GCC version myself and have not seen these
> in any test builds with that or similar GCC versions. Am trying your
> build options now just to be sure.
>
>
> On the matter of BSD's, since they provide clang as the
> default compiler
> they (FreeBSD at least) build with clan/clang++ without any need for
> CC/CXX setting. We have Jenkins tests for that.
>
>
> >
> > Great to known you are on this package, I thought there was
> only Luigi
> > Gangitano ([hidden email]) for ages...
> >
>
> Welcome. There are several of us, with Luigi as team lead.
>
> Amos
> _______________________________________________
> squid-users mailing list
> [hidden email]
> http://lists.squid-cache.org/listinfo/squid-users
>

_______________________________________________
squid-users mailing list
[hidden email]
http://lists.squid-cache.org/listinfo/squid-users
Reply | Threaded
Open this post in threaded view
|

Re: using clang to compile squid 4-5

Amos Jeffries
Administrator
On 31/01/19 5:12 am, L.P.H. van Belle wrote:

> Hai,
>
> Good to hear there are more then Luigi :-)
>
> I builded debian packages yesterday for squid 4.5
> Which was pretty simple and worked fine in the end.
>
> Get the source of 4.4  ( apt-get source -t unstable squid  )
> Copy the debian folder from 4.4 into the 4.5 folder.
>
> And changed in the changelog the squid version, builded fine.
> Test build failed, my change was.
>
> diff squid-4.4/debian/rules squid-4.5/debian/rules
> 22c22
> < DEB_INSTALL_DOCS_squid-common := debian/copyright CONTRIBUTORS CREDITS QUICKSTART RELEASENOTES.html SPONSORS
> ---
>> DEB_INSTALL_DOCS_squid-common := debian/copyright CONTRIBUTORS CREDITS QUICKSTART SPONSORS
>
> 4.5 was missing : RELEASENOTES.html
> Uhm must say, i builded the "squid-4.5-20190128-r568e66b7c" version.

Aye, looking into that is on my worklist for this weekend while waiting
for the release prep testing.


>
> Working now on a backport for debian stretch.
>
> Thank for all the good work Amos. ( and Luigi ) !
>
> @Amos, any chance to upload 4.5 to unstable or experimental?
> I was hoping that 4.5 would get into buster, im guessing thats not going to happen?
>

Um, that will depend on Luigi's time between now and then. We have until
the 10th to roll and test it.

I have updated the version in the team repository (pushed just now) but
the changes are relatively minor and 4.6 is due this weekend. If I can
replicate this strncpy issue in the next day a temporary fix for should
also be added before next upload.

Amos
_______________________________________________
squid-users mailing list
[hidden email]
http://lists.squid-cache.org/listinfo/squid-users
Reply | Threaded
Open this post in threaded view
|

Re: using clang to compile squid 4-5

Amos Jeffries
Administrator
On 31/01/19 9:22 am, Amos Jeffries wrote:

> On 31/01/19 5:12 am, L.P.H. van Belle wrote:
>> Hai,
>>
>> Good to hear there are more then Luigi :-)
>>
>> I builded debian packages yesterday for squid 4.5
>> Which was pretty simple and worked fine in the end.
>>
>> Get the source of 4.4  ( apt-get source -t unstable squid  )
>> Copy the debian folder from 4.4 into the 4.5 folder.
>>
>> And changed in the changelog the squid version, builded fine.
>> Test build failed, my change was.
>>
>> diff squid-4.4/debian/rules squid-4.5/debian/rules
>> 22c22
>> < DEB_INSTALL_DOCS_squid-common := debian/copyright CONTRIBUTORS CREDITS QUICKSTART RELEASENOTES.html SPONSORS
>> ---
>>> DEB_INSTALL_DOCS_squid-common := debian/copyright CONTRIBUTORS CREDITS QUICKSTART SPONSORS
>>
>> 4.5 was missing : RELEASENOTES.html
>> Uhm must say, i builded the "squid-4.5-20190128-r568e66b7c" version.
>
> Aye, looking into that is on my worklist for this weekend while waiting
> for the release prep testing.
>

I am not seeing this error with GCC-8.2.0-15 on the Debian package or
the pkg-squid repo with v4.5 release in it, or my local v4 checkout of
r568e66b7c.


Amos
_______________________________________________
squid-users mailing list
[hidden email]
http://lists.squid-cache.org/listinfo/squid-users
Reply | Threaded
Open this post in threaded view
|

Re: using clang to compile squid 4-5

graf huy
Hi,

>I'm not sure I follow that. Are you building with patched GCC? or a
>patched libc? or something else?

No, these are the versions used.

(ldd --version)

ldd (Debian GLIBC 2.28-5) 2.28

Copyright © 2018 Free Software Foundation, Inc.



(gcc -v)

Using built-in specs.

COLLECT_GCC=gcc

COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper

OFFLOAD_TARGET_NAMES=nvptx-none

OFFLOAD_TARGET_DEFAULT=1

Target: x86_64-linux-gnu

Configured with: ../src/configure -v --with-pkgversion='Debian 8.2.0-14' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu

Thread model: posix

gcc version 8.2.0 (Debian 8.2.0-14)


Kind regards.
Le vendredi 1 février 2019 à 08:38:32 UTC+1, Amos Jeffries <[hidden email]> a écrit :


On 31/01/19 9:22 am, Amos Jeffries wrote:

> On 31/01/19 5:12 am, L.P.H. van Belle wrote:
>> Hai,
>>
>> Good to hear there are more then Luigi :-)
>>
>> I builded debian packages yesterday for squid 4.5
>> Which was pretty simple and worked fine in the end.
>>
>> Get the source of 4.4  ( apt-get source -t unstable squid  )
>> Copy the debian folder from 4.4 into the 4.5 folder.
>>
>> And changed in the changelog the squid version, builded fine.
>> Test build failed, my change was.
>>
>> diff squid-4.4/debian/rules squid-4.5/debian/rules
>> 22c22
>> < DEB_INSTALL_DOCS_squid-common := debian/copyright CONTRIBUTORS CREDITS QUICKSTART RELEASENOTES.html SPONSORS
>> ---
>>> DEB_INSTALL_DOCS_squid-common := debian/copyright CONTRIBUTORS CREDITS QUICKSTART SPONSORS
>>
>> 4.5 was missing : RELEASENOTES.html
>> Uhm must say, i builded the "squid-4.5-20190128-r568e66b7c" version.
>
> Aye, looking into that is on my worklist for this weekend while waiting
> for the release prep testing.
>

I am not seeing this error with GCC-8.2.0-15 on the Debian package or
the pkg-squid repo with v4.5 release in it, or my local v4 checkout of

r568e66b7c.


Amos
_______________________________________________
squid-users mailing list
[hidden email]
http://lists.squid-cache.org/listinfo/squid-users

_______________________________________________
squid-users mailing list
[hidden email]
http://lists.squid-cache.org/listinfo/squid-users
Reply | Threaded
Open this post in threaded view
|

Re: using clang to compile squid 4-5

Amos Jeffries
Administrator
On 1/02/19 11:17 pm, graf huy wrote:
> Hi,
>
>>I'm not sure I follow that. Are you building with patched GCC? or a
>>patched libc? or something else?
>
> No, these are the versions used.
>

Hmm. That is odd. With the exception of my GCC being one patch ahead,
mine are identical. I have followed each GCC update, so would have
tested with that *-14 for a while when it was latest and have not seen
these errors at any point.


It still may be a libc and/or kernel headers issue, but those should
affect clang builds too.

Amos
_______________________________________________
squid-users mailing list
[hidden email]
http://lists.squid-cache.org/listinfo/squid-users