Commit Graph

81 Commits

Author SHA1 Message Date
H. Peter Anvin (Intel)
50200cc0d3 configure.ac: add option to compile with suggestion warnings
Add a configure option to enable suggestion warnings, currently a set
of -Wsuggest-attribute=* warnings.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-30 17:37:42 -07:00
H. Peter Anvin (Intel)
e1f0b35af0 configure.ac: also try -std=c99
If -std=c17 and -std=c11 don't work, try -std=c99 as well.
-std=c90 is unlikely to work because of the requirement for "long
long" on L32 platforms, which isn't likely to be supported on a pure
C90 compiler.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-09 19:33:26 -07:00
H. Peter Anvin (Intel)
5c90a7c237 autoconf: use -std=c17 or -std=c11 if available
If the compiler supports it, use -std=c17 or -std=c11. Hopefully, this
will give us more predictable behavior in some cases.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-09 19:26:27 -07:00
H. Peter Anvin (Intel)
e8d6bbacd4 configure.ac: if we have a C17/C11-compatible compiler, use it
Enable -std=c17 or -std=c11 for compilers that handle them.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-09 19:12:25 -07:00
H. Peter Anvin (Intel)
abcdf8356a configure.ac: better tests for typeof, snprintf, vsnprintf
With some combinations of options tests for typeof, snprintf, and
vsnprintf end up with warnings promoted to errors, which then trigger
incorrect results for these tests. Move the typeof test to the end,
and write specific tests for snprintf and vsnprintf.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-09 19:04:28 -07:00
H. Peter Anvin (Intel)
30844a4c62 offsetin(): use typeof() if the compiler supports it
If the C compiler has typeof(), we can use a safer implementation of
the offsetin() macro by using typeof(). Since typeof() isn't standard
(yet?) autoconf has to test for it.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-06 12:39:14 -07:00
H. Peter Anvin (Intel)
70f0d04ee5 configure.ac: -enable-... breaks other compilers, so hope for clang 10
The -enable-... option to enable -ftrivial-auto-var-init=zero breaks
linking not just on clang but on other compilers (gcc) too. Drop it;
this feature is enabled by default in clang 10.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-06 11:30:22 -07:00
H. Peter Anvin (Intel)
e2040291ec config/unconfig.h: generate by Makefile, not autogen.sh
config/unconfig.h really is no different than the other perlreq files,
so move it into the Makefile. This has the extra advantage that
config/unconfig.h no longer needs to be kept in the source repository.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-06 11:12:03 -07:00
H. Peter Anvin (Intel)
0da8a88c62 clang: add -ftrivial-auto-var-init=zero
The clang behavior is sometimes really weird, and extremely hard to
debug, when uninitialized variables are used even if the value cancels
out in an expression. It also depends on optimization level, etc.

-ftrivial-auto-var-init=zero makes the behavior
predictable. Unfortunately it also needs a really weird "enable"
option, and it issues a warning about an unused command line option on
link, which may get promoted to error, so silence the warning before
doing anything else.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-07-06 10:19:38 -07:00
H. Peter Anvin (Intel)
65ab3ab197 clang: mark inline functions unused and add warning options
clang, unlike gcc, will warn on inline functions which are
unused. This can happen if a function is either intended to be used in
the future, or it is only used under certain config options. Mark
those functions with the "unused" attribute; not only does it quiet
the warning, but it also documents it for the user.

Shuffle around the warning options in configure and add a few more
that are specific to clang.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-06-30 10:14:21 -07:00
H. Peter Anvin (Intel)
5b4de52083 BR 3392667: more reasonable limit for expression descent
Set an expression descent limit to 8192, which is more reasonable to
expect to work on most platforms. Furthermore, if getrlimit() exists,
then try to use it to see if we need to further limit the size.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-06-01 13:21:05 -07:00
H. Peter Anvin (Intel)
941c75a2b2 Makefile portability improvement, build nasmdoc.pdf.xz
Significantly improve the portability/reliability of a general
make command. Build a .pdf.xz version of the documentation,
using an uncompressed pdf as basis.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2020-05-26 14:13:31 -07:00
H. Peter Anvin
97ea4adcf0 config/unconfig.h: eliminate #undef directives
config/config.h as generated by autoconf has #undef directives
commented out, but the autoheader-generated template contains them,
and config/unconfig.h should not contain them. Re-introduce
config/config.h.in, and postprocess it to generate config/unconfig.h
by commenting out all the #undef directives, just as configure does.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2019-10-03 21:34:42 -07:00
H. Peter Anvin
eaef851689 configure.ac: look for unconfig.h not uninit.h... 2019-08-27 15:13:15 -07:00
H. Peter Anvin (Intel)
480d5e2c8b BR 3392601: allow the user to disable pedantic warnings
--disable-pedantic passed to configure will now disable
-W, -Wc90-c99-compat, and -pedantic.

Requested-by: Orzkan Sezer <sezeroz@gmail.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2019-08-16 00:52:26 -07:00
H. Peter Anvin (Intel)
8b6e6bf04f config.h: separate function and function pointer attributes; automate
Separate out function and function pointer attributes, as not all
versions of all compilers support both.

Have macros related to function attributes auto-generated by
autoheader. As a result, rename config.h.in to unconfig.h, to make it
more obvious that it is really intended to be included from some C
programs.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2019-08-16 00:08:27 -07:00
H. Peter Anvin (Intel)
471120f485 file.c: handle long pathnames on Windows
Windows supports pathnames up to 32767 UTF-16 characters, but using
the standard interfaces only up to 260 characters. Wrap the functions
that take filenames on Windows.

Clean up the compatiblity layers some more for reduced #ifdefs.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2019-05-15 13:07:21 -07:00
H. Peter Anvin (Intel)
9bb55bd127 Merge branch 'evalmacro'
Resolved Conflicts:
	asm/preproc.c
	output/elf.h
	output/outelf.c
	output/outelf.h
	version

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2019-04-24 11:14:43 -07:00
H. Peter Anvin
efee3ea312 configure.ac: add --enable-profiling option
Add option to enable profiling without having to modify Makefile.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2019-02-25 21:00:43 -08:00
H. Peter Anvin
0bddd0f1b1 autoconf: move aux directory, define AC_CONFIG_AUX_DIR()
The name "aux" is reserved on Windows platforms, a legacy from CP/M
via MS-DOS. Rename it to "helpers".

Turns out that that directory wasn't actually used properly, because
AC_CONFIG_AUX_DIR was never defined, and there was a redundant copy of
install-sh checked into the base of the source tree.

Reported-by: Ehsan Alem Mohammad Ghasemlou <e.ghasemloo@gmail.com>
NASM-Bugzilla: https://bugzilla.nasm.us/show_bug.cgi?id=3392560
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2019-02-22 01:18:04 -08:00
H. Peter Anvin
06f72bb968 Test for the mempcpy() function and add alternative if missing
If memcpy() doesn't exist, then add an inline alternative using
memcpy().

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-26 06:22:47 -08:00
Cyrill Gorcunov
8274623093 build: Add missing PA_ADD_LDFLAGS helper
Fixes b0121dc312

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2018-12-23 17:22:44 +03:00
H. Peter Anvin
b0121dc312 autoconf: use librarized autoconf setup
I have been setting up a cross-project librarized autoconf setup; use
it for NASM as well.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-12-22 18:17:16 -08:00
H. Peter Anvin (Intel)
b7f24e7715 nasm_assert(): try to run at compile time if possible
Try to make nasm_assert() do a static assert if the argument can be
evaluated at compile time by any particular compiler. We also provide
nasm_try_static_assert() which will assert a compile-time expression
if and only if we can determine we have a constant at compile time
*and* we know that the compiler has a way to handle it.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-14 15:42:03 -08:00
H. Peter Anvin (Intel)
7dc5b23920 configure: make section garbage collect the default
Section garbage collect really is quite useful, and it makes managing
library source code management a little bit less stressful. It has
been used by the official builds for a while now, turn it on by
default.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-13 22:51:22 -08:00
H. Peter Anvin (Intel)
7bb13eac11 strlist: can be unique or not, add printf functions
Make it a selectable option at allocation time if a strlist should
contain only unique strings or not. If not, we omit the hash table and
strlist_find() will not do anything.

Add printf()-style functions to a strlist.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-13 22:48:14 -08:00
H. Peter Anvin (Intel)
8e08fb6da7 Merge remote-tracking branch 'origin/nasm-2.14.xx'
Resolved Conflicts:
	asm/assemble.c
	asm/directiv.c
	asm/error.c
	asm/float.c
	asm/labels.c
	asm/listing.c
	asm/nasm.c
	asm/parser.c
	asm/preproc.c
	asm/stdscan.c
	include/error.h
	output/outelf.c
	version

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-12 18:05:52 -08:00
H. Peter Anvin (Intel)
64b56eaa39 configure: add -Wno-shift-negative-value
Shifting negative values is undefined in standard C, but we have tons
of dependencies that signed arithmetic is 2's-complement in the code
anyway, and on gcc-like compilers we pass the -fwrapv option to
indicate exactly that. Therefore, this is not a valid warning in our
case and should be suppressed.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-12 15:56:28 -08:00
H. Peter Anvin (Intel)
eb5b3ae0d3 nasmlib: Add nasm_(v)asprintf()
Add a version of (v)asprintf(), which allocates a string on the
heap. Unlike the standard version of (v)asprintf(), we return the
pointer; if one wants the length of the string then one can simply use
the %n pattern.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2018-12-12 14:34:34 -08:00
H. Peter Anvin
1350620bf1 ctype: create our own ctype table
Create our own ctype table where we can do the tests we want to do
cheaply, instead of calling ctype functions and then adding additional
tests all over the code.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-11-28 14:55:58 -08:00
H. Peter Anvin
cd133a6f2d Merge remote-tracking branch 'origin/nasm-2.14.xx'
Fixes for various build problems.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-06-15 17:44:30 -07:00
H. Peter Anvin
48fd154d1c configure.ac: drop -O3; it is excessive and produces huge code
There is no reason to use -O3; it causes code to be insanely
duplicated. Simplify the configure.ac file too.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-06-14 19:19:09 -07:00
H. Peter Anvin
c4e16f7e7c gcc: newer gcc trip on -Wstringop-truncation for valid uses of strncpy()
strncpy() is correctly used to fill in a zero-*padded* (not
zero-terminated) field in several places.  Make gcc not complain about
those uses.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-06-02 23:47:57 -07:00
H. Peter Anvin
7310d0bd5b configure.ac: add -fvisibility=hidden if supported
None of our symbols are available for a dynamic library, and if they
were, there would be no point in allowing them to be overridden. This
optimizes code generation for global symbols.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-05-30 11:48:00 -07:00
H. Peter Anvin
740ec3572b malloc: simplify nasm_malloc code, add nasm_strcatn()
Simplify the nasm_malloc() code by moving the pointer check into a
common subroutine.

We can now issue a filename error even for failures like malloc().

Add support for the gcc sentinel attribute (verify that a list ends
with NULL).

Add a handful of safe_alloc attributes.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-05-30 11:40:42 -07:00
Cyrill Gorcunov
dd6a2cdcf4 Revert "compiler: Add fallthrough() helper"
This reverts commit 8ba28e13ea.
2018-02-25 22:25:57 +03:00
Cyrill Gorcunov
8ba28e13ea compiler: Add fallthrough() helper
https://bugzilla.nasm.us/show_bug.cgi?id=3392465

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2018-02-25 17:09:11 +03:00
H. Peter Anvin
281f5bd92c Merge branch 'master' of ssh://repo.or.cz/srv/git/nasm 2018-02-22 14:53:46 -08:00
H. Peter Anvin
6686fc627e Introduce cold function attribute
Attribute to deemphasize certain code paths.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2018-02-22 14:52:50 -08:00
H. Peter Anvin
99d45c850e Fix problem with C99 inlines and -Werror=missing-prototypes
Some older versions of gcc (gcc 4.2.1 at least) produce a warning,
promoted to error, on C99 inlines.  Do some work to figure out if we
need to fall back to GNU inline syntax.

Fix some issues with GNU inline syntax.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2018-02-20 12:34:17 -08:00
H. Peter Anvin
81b62b9f54 Eliminate filename length restrictions, remote ofmt->filename()
Get rid of remaining dependencies on FILENAME_MAX, which ought to have
been removed a long time ago.

Remove ofmt->filename(); all implementations pretty much do the same
thing and there is absolutely no reason to duplicate that
functionality all over the place.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-12-20 13:38:20 -08:00
H. Peter Anvin
dcbaf677d4 error: add --enable-panic-abort config options
For debugging purposes, make it possible to force calling abort() on
ERR_PANIC.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-12-20 12:10:33 -08:00
H. Peter Anvin
e5033dfd1c configure.ac: add endian headers to configure test
- Add endian headers to the standard tests if present
- Check for __builtin_constant_p()

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-11-29 16:04:05 -08:00
H. Peter Anvin
cae5d06184 More autoconf modernizations; upgrade AC_PREREQ to 2.69
Make further autoconf rule improvements and update the required
version of autoconf to 2.69.  That version is now 5+ years old and
although there might be older versions which have the prerequisite
macros they are known to have lots of bugs, and we can't really test
them.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-11-08 10:22:10 -08:00
H. Peter Anvin
ece809789e Merge remote-tracking branch 'origin/nasm-2.13.xx'
Resolved conflicts:
	version

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-11-01 10:37:18 -07:00
H. Peter Anvin
53259e8aaf configure.ac: more debugging options
Make -O0 imply -fno-omit-frame-pointer
Add options to compile/link with AddressSanitizer and
UndefinedSanitizer.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2017-10-11 16:47:59 -07:00
Cyrill Gorcunov
d7a5473368 configure: Add --enable-gdb option
When one needs to run nasm under GDB

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-08-16 14:59:25 -07:00
Cyrill Gorcunov
fdbf7012ba configure: Add --enable-gdb option
When one needs to run nasm under GDB

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2017-07-29 16:07:40 +03:00
H. Peter Anvin
573112ee86 endian.h: can be called sys/endian.h or machine/endian.h
On some platforms, endian.h may exist but be called sys/endian.h or
machine/endian.h.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-24 13:28:14 -07:00
H. Peter Anvin
d3e22572b3 Clean up byteorder functions
Move byte order handling functions to their own header file, and try
to be more specific about how exactly to handle things.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2017-04-24 13:01:08 -07:00