mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix compile when using tcc >0.9.27 (#238)
This allows ksh to be compiled with versions of tcc that define __dso_handle in libtcc1.a, i.e., versions as of this commit: https://repo.or.cz/tinycc.git/commit/dd60b20c Older versions of tcc still fail to compile ksh, although now they fail after reaching the libdll feature test. I'm not sure if fixing that is feasible since even if I hack out the failing libdll feature test, ksh fails to link with a '__dso_handle' error. src/lib/libast/comp/atexit.c, src/lib/libast/features/lib, src/lib/libast/vmalloc/vmexit.c: - From what I've been able to gather the only OSes with support for on_exit are Linux and SunOS 4. However, on_exit takes two arguments, so the macro that defines it as taking one argument is incorrect. Since Solaris (SunOS 5) no longer has this call and the macro breaks on Linux, the clean fix is to remove it (atexit(3) is used instead). src/lib/libast/include/ast.h: - When compiling with tcc on FreeBSD, pretend to be gcc 2.95.3 instead of gcc 9.3.0. This stops /usr/include/math.h from activating gcc 3.0+ math compiler builtins that don't exist on tcc, while still identifying as gcc which is needed to avoid other FreeBSD system header breakage. src/cmd/builtin/Mamfile, src/cmd/builtin/features/pty, src/lib/libdll/Mamfile, src/lib/libdll/features/dll: - tcc forbids combining the -c compiler flag with -l* linker flags. Use the -lm flag in the iffe feature tests instead of the Mamfiles. This avoids iffe combining -lm with the -c flag. src/lib/libast/vmalloc/malloc.c: - Fix failure to compile with -D_std_malloc. This patch is from OpenSUSE: https://build.opensuse.org/package/view_file/shells/ksh/ksh93-malloc-hook.dif As it turns out tcc needs this change to build ksh with -D_std_malloc, so it has been applied. Co-authored-by: Martijn Dekker <martijn@inlv.org> Resolves: https://github.com/ksh93/ksh/issues/232
This commit is contained in:
parent
ca3ec2000c
commit
22e044c339
9 changed files with 20 additions and 15 deletions
|
@ -37,7 +37,7 @@ make install
|
|||
meta FEATURE/pty features/%>FEATURE/% features/pty pty
|
||||
make features/pty
|
||||
done features/pty
|
||||
exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${CCFLAGS} ${LDFLAGS} -lm" ref ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libast} ${mam_libcmd} : run features/pty
|
||||
exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${CCFLAGS} ${LDFLAGS}" ref ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libast} ${mam_libcmd} : run features/pty
|
||||
done FEATURE/pty generated
|
||||
make ${PACKAGE_ast_INCLUDE}/ast_time.h implicit
|
||||
done ${PACKAGE_ast_INCLUDE}/ast_time.h
|
||||
|
|
|
@ -13,7 +13,7 @@ lib openpty,_getpty,ptsname -lutil
|
|||
lib grantpt,unlockpt,posix_openpt stdlib.h
|
||||
lib cfmakeraw termios.h
|
||||
|
||||
tst - output{
|
||||
tst - -lm output{
|
||||
#include <fcntl.h>
|
||||
#if _lib_ptsname
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -34,11 +34,7 @@ NoN(atexit)
|
|||
|
||||
#else
|
||||
|
||||
#if _lib_onexit || _lib_on_exit
|
||||
|
||||
#if !_lib_onexit
|
||||
#define onexit on_exit
|
||||
#endif
|
||||
#if _lib_onexit
|
||||
|
||||
extern int onexit(void(*)(void));
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ lib getopt,getsubopt,getopt_long,getopt_long_only
|
|||
lib glob,index,iswblank,iswctype,killpg,link,localeconv,madvise
|
||||
lib mbtowc,mbrtowc,memalign,memchr,memcpy,memdup,memmove,memset
|
||||
lib mkdir,mkfifo,mktemp,mktime
|
||||
lib mount,on_exit,onexit,opendir,pathconf
|
||||
lib mount,onexit,opendir,pathconf
|
||||
lib readlink,remove,rename,rewinddir,rindex,rmdir,setlocale
|
||||
lib setpgid,setpgrp,setpgrp2,setreuid,setsid,setuid,sigaction
|
||||
lib sigprocmask,sigsetmask,sigunblock,sigvec,socketpair
|
||||
|
|
|
@ -78,6 +78,19 @@ struct _sfio_s;
|
|||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* tcc on FreeBSD: Avoid using nonexistent math
|
||||
* builtins by pretending to be an ancient gcc.
|
||||
*/
|
||||
#if __TINYC__ && __GNUC__ >= 3 && __FreeBSD__
|
||||
#undef __GNUC__
|
||||
#undef __GNUC_MINOR__
|
||||
#undef __GNUC_PATCHLEVEL__
|
||||
#define __GNUC__ 2
|
||||
#define __GNUC_MINOR__ 95
|
||||
#define __GNUC_PATCHLEVEL__ 3
|
||||
#endif
|
||||
|
||||
/*
|
||||
* exit() support -- this matches shell exit codes
|
||||
*/
|
||||
|
|
|
@ -1040,12 +1040,8 @@ extern Void_t* F1(_ast_valloc, size_t,n) { return valloc(n); }
|
|||
|
||||
#if !_UWIN
|
||||
|
||||
#if !_malloc_hook
|
||||
|
||||
#include <malloc.h>
|
||||
|
||||
#endif
|
||||
|
||||
typedef struct mallinfo Mallinfo_t;
|
||||
typedef struct mstats Mstats_t;
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ int type;
|
|||
return type;
|
||||
}
|
||||
|
||||
#endif /* _lib_onexit || _lib_on_exit */
|
||||
#endif /* _lib_onexit */
|
||||
|
||||
#endif /*!PACKAGE_ast*/
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ make install
|
|||
done features/dll
|
||||
bind -ldl dontcare
|
||||
bind -last
|
||||
exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${CCFLAGS} ${LDFLAGS} -lm" ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdl} ${mam_libast} : run features/dll
|
||||
exec - iffe ${IFFEFLAGS} -v -c "${CC} ${mam_cc_FLAGS} ${KSH_RELFLAGS} ${CCFLAGS} ${LDFLAGS}" ref ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -I${PACKAGE_ast_INCLUDE} -I${INSTALLROOT}/include ${mam_libdl} ${mam_libast} : run features/dll
|
||||
done FEATURE/dll generated
|
||||
exec - cmp 2>/dev/null -s FEATURE/dll dlldefs.h || { rm -f dlldefs.h; silent test -d . || mkdir .; cp FEATURE/dll dlldefs.h; }
|
||||
done dlldefs.h generated
|
||||
|
|
|
@ -74,7 +74,7 @@ tst run{
|
|||
esac
|
||||
echo "#define _DLL_NEXT_PATH \"$lib\""
|
||||
}end
|
||||
tst - output{
|
||||
tst - -lm output{
|
||||
#include <math.h>
|
||||
#if defined(__MVS__) && !defined(__SUSV3)
|
||||
#define __SUSV3 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue