@ -12,13 +12,18 @@ option(WASI_SDK_INCLUDE_TESTS "Whether or not to build tests by default" OFF)
set ( wasi_tmp_install ${ CMAKE_CURRENT_BINARY_DIR } /install )
set ( wasi_tmp_install ${ CMAKE_CURRENT_BINARY_DIR } /install )
set ( wasi_sysroot ${ wasi_tmp_install } /share/wasi-sysroot )
set ( wasi_sysroot ${ wasi_tmp_install } /share/wasi-sysroot )
set ( wasi_resource_dir ${ wasi_tmp_install } /lib/clang/ ${ clang_version } )
# F o r c e u s a g e o f t h e c u s t o m - b u i l t r e s o u r c e - d i r a n d s y s r o o t f o r t h e r e s t o f t h e
# w a s i c o m p i l e s .
add_compile_options ( -resource-dir ${ wasi_resource_dir } )
add_compile_options ( --sysroot ${ wasi_sysroot } )
if ( WASI_SDK_DEBUG_PREFIX_MAP )
if ( WASI_SDK_DEBUG_PREFIX_MAP )
add_compile_options (
add_compile_options (
- f d e b u g - p r e f i x - m a p = $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } = w a s i s d k : / / v $ { w a s i _ s d k _ v e r s i o n } )
- f d e b u g - p r e f i x - m a p = $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } = w a s i s d k : / / v $ { w a s i _ s d k _ v e r s i o n } )
endif ( )
endif ( )
# D e f a u l t a r g u m e n t s f o r b u i l d s o f c m a k e projects ( mostly LLVM-based ) t o f o r w a r d
# D e f a u l t a r g u m e n t s f o r b u i l d s o f c m a k e projects ( mostly LLVM-based ) t o f o r w a r d
# a l o n g m u c h o f o u r o w n c o n f i g u r a t i o n i n t o t h e s e p r o j e c t s .
# a l o n g m u c h o f o u r o w n c o n f i g u r a t i o n i n t o t h e s e p r o j e c t s .
set ( default_cmake_args
set ( default_cmake_args
@ -45,7 +50,6 @@ endif()
# c o m p i l e r - r t b u i l d l o g i c
# c o m p i l e r - r t b u i l d l o g i c
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
set ( compiler_rt_dst ${ wasi_tmp_install } /lib/clang/ ${ clang_version } )
ExternalProject_Add ( compiler-rt-build
ExternalProject_Add ( compiler-rt-build
S O U R C E _ D I R " $ { l l v m _ p r o j _ d i r } / c o m p i l e r - r t "
S O U R C E _ D I R " $ { l l v m _ p r o j _ d i r } / c o m p i l e r - r t "
C M A K E _ A R G S
C M A K E _ A R G S
@ -58,7 +62,7 @@ ExternalProject_Add(compiler-rt-build
- D C O M P I L E R _ R T _ D E F A U L T _ T A R G E T _ O N L Y = O N
- D C O M P I L E R _ R T _ D E F A U L T _ T A R G E T _ O N L Y = O N
- D C M A K E _ C _ C O M P I L E R _ T A R G E T = w a s m 3 2 - w a s i
- D C M A K E _ C _ C O M P I L E R _ T A R G E T = w a s m 3 2 - w a s i
- D C O M P I L E R _ R T _ O S _ D I R = w a s i
- D C O M P I L E R _ R T _ O S _ D I R = w a s i
- D C M A K E _ I N S T A L L _ P R E F I X = $ { co m p i l e r _ r t _ d s t }
- D C M A K E _ I N S T A L L _ P R E F I X = $ { wa s i _ r e s o u r c e _ d i r }
E X C L U D E _ F R O M _ A L L O N
E X C L U D E _ F R O M _ A L L O N
U S E S _ T E R M I N A L _ C O N F I G U R E O N
U S E S _ T E R M I N A L _ C O N F I G U R E O N
U S E S _ T E R M I N A L _ B U I L D O N
U S E S _ T E R M I N A L _ B U I L D O N
@ -69,26 +73,30 @@ ExternalProject_Add(compiler-rt-build
# a r o u n d s o m e h e a d e r s a n d m a k e c o p i e s o f t h e ` w a s i ` d i r e c t o r y a s ` w a s i p 1 ` a n d
# a r o u n d s o m e h e a d e r s a n d m a k e c o p i e s o f t h e ` w a s i ` d i r e c t o r y a s ` w a s i p 1 ` a n d
# ` w a s i p 2 `
# ` w a s i p 2 `
execute_process (
execute_process (
C O M M A N D $ { C M A K E _ C _ C O M P I L E R } - p r i n t - r un t i m e - d i r
C O M M A N D $ { C M A K E _ C _ C O M P I L E R } - p r i n t - r es o u r c e - d i r
O U T P U T _ V A R I A B L E c l a n g _ r un t i m e _ d i r
O U T P U T _ V A R I A B L E c l a n g _ r es o u r c e _ d i r
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
cmake_path ( GET clang_runtime_dir PARENT_PATH clang_runtime_libdir ) # c h o p o f f ` w a s i `
cmake_path ( GET clang_runtime_libdir PARENT_PATH clang_sysroot_dir ) # c h o p o f f ` l i b `
add_custom_target ( compiler-rt-post-build
add_custom_target ( compiler-rt-post-build
# T h e ` $ { w a s i _ r e s o u r c e _ d i r } ` f o l d e r i s g o i n g t o g e t u s e d a s ` - r e s o u r c e - d i r `
# f o r f u t u r e c o m p i l e s . C o p y t h e h o s t c o m p i l e r ' s o w n h e a d e r s i n t o t h i s
# d i r e c t o r y t o e n s u r e t h a t a l l h o s t - d e f i n e d h e a d e r s a l l w o r k a s w e l l .
C O M M A N D $ { C M A K E _ C O M M A N D } - E c o p y _ d i r e c t o r y
C O M M A N D $ { C M A K E _ C O M M A N D } - E c o p y _ d i r e c t o r y
$ { c l a n g _ s y s r o o t _ d i r } $ { c o m p i l e r _ r t _ d s t }
$ { c l a n g _ r e s o u r c e _ d i r } / i n c l u d e $ { w a s i _ r e s o u r c e _ d i r } / i n c l u d e
# C o p y t h e ` l i b / w a s i ` f o l d e r t o ` l i b c / w a s i { p 1 , p 2 } ` t o e n s u r e t h a t t h o s e
# O S - s t r i n g s a l s o w o r k f o r l o o k i n g u p t h e c o m p i l e r - r t . a f i l e .
C O M M A N D $ { C M A K E _ C O M M A N D } - E c o p y _ d i r e c t o r y
C O M M A N D $ { C M A K E _ C O M M A N D } - E c o p y _ d i r e c t o r y
$ { c o m p i l e r _ r t _ d s t } / l i b / w a s i $ { c o m p i l e r _ r t _ d s t } / l i b / w a s i p 1
$ { wa s i _ r e s o u r c e _ d i r } / l i b / w a s i $ { wa s i _ r e s o u r c e _ d i r } / l i b / w a s i p 1
C O M M A N D $ { C M A K E _ C O M M A N D } - E c o p y _ d i r e c t o r y
C O M M A N D $ { C M A K E _ C O M M A N D } - E c o p y _ d i r e c t o r y
$ { c o m p i l e r _ r t _ d s t } / l i b / w a s i $ { c o m p i l e r _ r t _ d s t } / l i b / w a s i p 2
$ { w a s i _ r e s o u r c e _ d i r } / l i b / w a s i $ { w a s i _ r e s o u r c e _ d i r } / l i b / w a s i p 2
C O M M A N D $ { C M A K E _ C O M M A N D } - E c o p y _ d i r e c t o r y _ i f _ d i f f e r e n t
$ { c o m p i l e r _ r t _ d s t } / l i b $ { c l a n g _ r u n t i m e _ l i b d i r }
C O M M E N T " f i n a l i z i n g c o m p i l e r - r t i n s t a l l a t i o n "
C O M M E N T " f i n a l i z i n g c o m p i l e r - r t i n s t a l l a t i o n "
)
)
add_dependencies ( compiler-rt-post-build compiler-rt-build )
add_dependencies ( compiler-rt-post-build compiler-rt-build )
add_custom_target ( compiler-rt DEPENDS compiler-rt-build compiler-rt-post-build )
add_custom_target ( compiler-rt DEPENDS compiler-rt-build compiler-rt-post-build )
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# w a s i - l i b c b u i l d l o g i c
# w a s i - l i b c b u i l d l o g i c
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =