-Wa,--divide option for GNU Assembler

35 views
Skip to first unread message

Jeffrey Walton

unread,
Jun 8, 2016, 7:17:10 PM6/8/16
to Crypto++ Users
Hi Everyone,

I noticed the Makefile has a line (http://github.com/weidai11/cryptopp/blob/master/GNUmakefile#L146):

ifneq ($(IS_SUN),0)
CXXFLAGS += -Wa,--divide # allow use of "/" operator
endif

That is a GNU Assembler option. It seems that block has not been executed in some time, including 5.6.2 and earlier:

    $ git checkout CRYPTOPP_5_6_2
    $ make -j 2
    g++ -DNDEBUG -g -O2 -pipe -c cryptlib
    ...

My question is, should this be fixed?

A quick testing pass on modern GCC, ancient GCC and non-GNU systems shows the fix is rather easy:

$ cat GNUmakefile.diff
diff --git a/GNUmakefile b/GNUmakefile
index 8ddef45..2d5e355 100755
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -82,6 +82,7 @@ GCC48_OR_LATER := $(shell $(CXX) -v 2>&1 | $(EGREP) -i -c "gcc version (4\.[8-9]
 GCC49_OR_LATER := $(shell $(CXX) -v 2>&1 | $(EGREP) -i -c "gcc version (4\.9|[5-9]\.)")
 
 ICC111_OR_LATER := $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\) ([2-9][0-9]|1[2-9]|11\.[1-9])")
+IS_GAS := $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(EGREP) -c "GNU assembler")
 GAS210_OR_LATER := $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(
...
+# Allow use of "/" operator for GNU Assembler
+ifeq ($(IS_GAS),1)
+CXXFLAGS += -Wa,--divide
 endif

Jeffrey Walton

unread,
Jun 15, 2016, 9:37:23 AM6/15/16
to Crypto++ Users

I noticed the Makefile has a line (http://github.com/weidai11/cryptopp/blob/master/GNUmakefile#L146):

ifneq ($(IS_SUN),0)
CXXFLAGS += -Wa,--divide # allow use of "/" operator
endif

That is a GNU Assembler option. It seems that block has not been executed in some time, including 5.6.2 and earlier:

    $ git checkout CRYPTOPP_5_6_2
    $ make -j 2
    g++ -DNDEBUG -g -O2 -pipe -c cryptlib
    ...

My question is, should this be fixed?

Let me be the first to answer that :)

Yes, its needed on Solaris (and maybe others):

$ g++ -DNDEBUG -g2 -O2 -fPIC -Wa,--divide -pipe -c integer.cpp
$

And without:

$ g++ -DNDEBUG -g2 -O2 -fPIC -pipe -c integer.cpp
{standard input}: Assembler messages:
{standard input}:6405: Error: unbalanced brackets in operand 2.
{standard input}:6406: Error: unbalanced brackets in operand 2.
{standard input}:6407: Error: unbalanced brackets in operand 2.
{standard input}:6408: Error: unbalanced brackets in operand 2.
...

And those {standard input} lines:

$ cat -n <S file> | grep "6405"
  6405  LMul16:movdqa xmm1, [esi+16/2*(1-(16-2*(16/2))*2)*16];

Jeff

Jeffrey Walton

unread,
Jun 15, 2016, 9:58:54 AM6/15/16
to Crypto++ Users

I noticed the Makefile has a line (http://github.com/weidai11/cryptopp/blob/master/GNUmakefile#L146):

ifneq ($(IS_SUN),0)
CXXFLAGS += -Wa,--divide # allow use of "/" operator
endif

That is a GNU Assembler option. It seems that block has not been executed in some time, including 5.6.2 and earlier:

    $ git checkout CRYPTOPP_5_6_2
    $ make -j 2
    g++ -DNDEBUG -g -O2 -pipe -c cryptlib
    ...

My question is, should this be fixed?

Let me be the first to answer that :)

Yes, its needed on Solaris (and maybe others):

Mouse

unread,
Jun 15, 2016, 3:41:06 PM6/15/16
to Jeffrey Walton, Crypto++ Users
Note that different versions of GNU assembler may behave differently wrt. this flag. 

Also note that g++ on Mac should be told to use the native Xcode assembler, which is accomplished by "-Wa,-q".

--
--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-user...@googlegroups.com.
More information about Crypto++ and this group is available at http://www.cryptopp.com.
---
You received this message because you are subscribed to the Google Groups "Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cryptopp-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Regards,
Mouse

Jeffrey Walton

unread,
Jun 15, 2016, 5:42:45 PM6/15/16
to Crypto++ Users, nolo...@gmail.com, mous...@gmail.com


On Wednesday, June 15, 2016 at 3:41:06 PM UTC-4, Mouse wrote:
Note that different versions of GNU assembler may behave differently wrt. this flag. 

Also note that g++ on Mac should be told to use the native Xcode assembler, which is accomplished by "-Wa,-q".


I was thinking about ping'ing you about it. I haven't seen you in a while, so I thought you were busy with other things.

Shall we give -Wa,q a go?

Jeff
 

Jeffrey Walton

unread,
Jun 15, 2016, 6:59:33 PM6/15/16
to Crypto++ Users, Jeffrey Walton, Uri Blumenthal
>> Also note that g++ on Mac should be told to use the native Xcode
>> assembler, which is accomplished by "-Wa,-q".
>
> I was thinking about ping'ing you about it. I haven't seen you in a while,
> so I thought you were busy with other things.
>
> Shall we give -Wa,q a go?

Committed at http://github.com/weidai11/cryptopp/commit/2cc5084d7aacb02bb0444e7a618256f26666c706.

Please report any problems.

Jeff
Reply all
Reply to author
Forward
0 new messages