mirror of
https://github.com/fluencelabs/wasmer
synced 2025-03-16 00:00:49 +00:00
Merge branch 'master' into feature/vm_refactor
This commit is contained in:
commit
e2a9bd4761
@ -7,12 +7,6 @@ jobs:
|
||||
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Pull submodules
|
||||
command: |
|
||||
# git pull --recurse-submodules
|
||||
git submodule sync --recursive
|
||||
git submodule update --recursive --init
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v4-test-cargo-cache-linux-{{ arch }}-{{ checksum "Cargo.lock" }}
|
||||
@ -34,12 +28,6 @@ jobs:
|
||||
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Pull submodules
|
||||
command: |
|
||||
# git pull --recurse-submodules
|
||||
git submodule sync --recursive
|
||||
git submodule update --recursive --init
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v4-cargo-cache-linux-{{ arch }}-{{ checksum "Cargo.lock" }}
|
||||
@ -82,12 +70,6 @@ jobs:
|
||||
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Pull submodules
|
||||
command: |
|
||||
# git pull --recurse-submodules
|
||||
git submodule sync --recursive
|
||||
git submodule update --recursive --init
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v4-cargo-cache-darwin-{{ arch }}-{{ checksum "Cargo.lock" }}
|
||||
@ -136,6 +118,26 @@ jobs:
|
||||
- target/release/deps
|
||||
key: v4-cargo-cache-darwin-{{ arch }}-{{ checksum "Cargo.lock" }}
|
||||
|
||||
test-rust-nightly:
|
||||
docker:
|
||||
- image: circleci/rust:latest
|
||||
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v4-test-cargo-cache-linux-{{ arch }}-{{ checksum "Cargo.lock" }}-nightly
|
||||
- run: sudo apt-get install -y cmake
|
||||
- run: rustup default nightly
|
||||
- run: make test
|
||||
- save_cache:
|
||||
paths:
|
||||
- /usr/local/cargo/registry
|
||||
- target/debug/.fingerprint
|
||||
- target/debug/build
|
||||
- target/debug/deps
|
||||
key: v4-test-cargo-cache-linux-{{ arch }}-{{ checksum "Cargo.lock" }}-nightly
|
||||
|
||||
publish-github-release:
|
||||
docker:
|
||||
- image: cibuilds/github
|
||||
@ -156,7 +158,7 @@ jobs:
|
||||
# VERSION_TAG=$(git describe --exact-match --tags)
|
||||
#if [ "$VERSION" == "$VERSION_TAG" ]; then
|
||||
# echo "Versions match, publishing to Github"
|
||||
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${VERSION} ./artifacts/
|
||||
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -soft ${VERSION} ./artifacts/
|
||||
#else
|
||||
# echo "Versions don't match. Wasmer output version (wasmer --version) is ${VERSION} while Git tag is ${VERSION_TAG}"
|
||||
# exit 1
|
||||
@ -178,6 +180,10 @@ workflows:
|
||||
filters:
|
||||
branches:
|
||||
only: master
|
||||
- test-rust-nightly:
|
||||
filters:
|
||||
branches:
|
||||
only: master
|
||||
# :
|
||||
# filters:
|
||||
# tags:
|
||||
|
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -1,4 +0,0 @@
|
||||
[submodule "cranelift"]
|
||||
path = cranelift
|
||||
url = https://github.com/wasmerio/cranelift.git
|
||||
fetchrecursesubmodules = true
|
497
ATTRIBUTIONS.md
Normal file
497
ATTRIBUTIONS.md
Normal file
@ -0,0 +1,497 @@
|
||||
# Wasmer Attributions
|
||||
|
||||
Wasmer is a community effort.
|
||||
In order to build the best WebAssembly runtime it's our duty to see how other runtimes are approaching the same space
|
||||
and get inspired from them on the things that they got right, so wasmer and its community can benefit from a solid
|
||||
foundation.
|
||||
|
||||
These are the different project that we used as inspiration:
|
||||
|
||||
- [Nebulet](https://github.com/nebulet/nebulet): as the base for creating a great Rust WebAssembly runtime
|
||||
- [WAVM](https://github.com/wavm/wavm): for their great integration and testing framework
|
||||
- [greenwasm](https://github.com/Kimundi/greenwasm): for their [spectests framework](https://github.com/Kimundi/greenwasm/tree/master/greenwasm-spectest)
|
||||
- [wasmtime](/wasmtime): on their [mmap implementation](https://github.com/CraneStation/wasmtime/blob/3f24098edc81cd9bf0f877fb7fba018cad0f039e/lib/runtime/src/mmap.rs).
|
||||
- [stackoverflow](https://stackoverflow.com/a/45795699/1072990): to create an efficient HashMap with pair keys.
|
||||
|
||||
We would love to hear from you if you think we can take inspiration from other projects that we haven't covered here.
|
||||
😊
|
||||
|
||||
## Licenses
|
||||
|
||||
### Nebulet
|
||||
|
||||
```
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
```
|
||||
|
||||
### WAVM
|
||||
|
||||
```
|
||||
Copyright (c) 2018, Andrew Scheidecker
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of WAVM nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The contents of [Test/spec](Test/spec) is covered by the license in [Test/spec/LICENSE](Test/spec/LICENSE).
|
||||
|
||||
[Source/ThirdParty/dtoa/dtoa.c](Source/ThirdParty/dtoa/dtoa.c) is covered by the license in that file.
|
||||
|
||||
[Source/ThirdParty/libunwind](Source/ThirdParty/libunwind) is covered by the license in [Source/ThirdParty/libunwind/LICENSE.TXT](Source/ThirdParty/libunwind/LICENSE.TXT).
|
||||
|
||||
[Source/ThirdParty/xxhash](Source/ThirdParty/xxhash) is covered by the license in [Source/ThirdParty/xxhash/LICENSE](Source/ThirdParty/xxhash/LICENSE).
|
||||
```
|
||||
|
||||
### Greenwasm
|
||||
|
||||
```
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
```
|
||||
|
||||
### Wasmtime
|
||||
|
||||
```
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
|
||||
--- LLVM Exceptions to the Apache 2.0 License ----
|
||||
|
||||
As an exception, if, as a result of your compiling your source code, portions
|
||||
of this Software are embedded into an Object form of such source code, you
|
||||
may redistribute such embedded portions in such Object form without complying
|
||||
with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
|
||||
|
||||
In addition, if you combine or link compiled forms of this Software with
|
||||
software that is licensed under the GPLv2 ("Combined Software") and if a
|
||||
court of competent jurisdiction determines that the patent provision (Section
|
||||
3), the indemnity provision (Section 9) or other Section of the License
|
||||
conflicts with the conditions of the GPLv2, you may retroactively and
|
||||
prospectively choose to deem waived or otherwise exclude such Section(s) of
|
||||
the License, but only in their entirety and only with respect to the Combined
|
||||
Software.
|
||||
```
|
||||
|
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -891,7 +891,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmer"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
dependencies = [
|
||||
"byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"console 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -916,18 +916,18 @@ dependencies = [
|
||||
"target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wabt 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasmparser 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasmparser 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmparser"
|
||||
version = "0.20.0"
|
||||
version = "0.22.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "wasmparser"
|
||||
version = "0.22.1"
|
||||
version = "0.23.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
@ -1058,8 +1058,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||
"checksum wabt 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff1f0f87e467255240c1faf5cf13a04410723407840d7733e75967224e191a5"
|
||||
"checksum wabt-sys 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0cc8982bfe0a923f152e96d991e50a6f97fe73ca4af6d9d84d76634f03051fa2"
|
||||
"checksum wasmparser 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2a75e0c3fe9a4d4fd91901348a5be05ba4791e29dda89e8596bfe87900ba7edc"
|
||||
"checksum wasmparser 0.22.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f46e666ecb4a406483a59a49f9d0c17f327e70da53a128eccddae2eadb95865c"
|
||||
"checksum wasmparser 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b5e01c420bc7d36e778bd242e1167b079562ba8b34087122cc9057187026d060"
|
||||
"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
|
||||
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "wasmer"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
authors = ["Syrus Akbary <me@syrusakbary.com>"]
|
||||
edition = "2018"
|
||||
repository = "https://github.com/wasmerio/wasmer"
|
||||
@ -36,7 +36,7 @@ error-chain = "0.12.0"
|
||||
errno = "0.2.4"
|
||||
structopt = "0.2.11"
|
||||
wabt = "0.7.2"
|
||||
wasmparser = "0.20.0"
|
||||
wasmparser = "0.23.0"
|
||||
winapi = "0.3.6"
|
||||
region = "0.3.0"
|
||||
# spin = "0.4.10"
|
||||
|
@ -31,8 +31,8 @@ wasmer run examples/nginx/nginx.wasm -- -p examples/nginx -c nginx.conf
|
||||
To build this project you will need Rust and Cargo.
|
||||
|
||||
```sh
|
||||
# checkout code and associated submodules
|
||||
git clone --recursive https://github.com/wasmerio/wasmer.git
|
||||
# checkout code
|
||||
git clone https://github.com/wasmerio/wasmer.git
|
||||
cd wasmer
|
||||
|
||||
# install tools
|
||||
@ -76,3 +76,5 @@ If you would like to know how Wasmer works under the hood, please visit our [ARC
|
||||
## License
|
||||
|
||||
MIT/Apache-2.0
|
||||
|
||||
<small>[Attributions](./ATTRIBUTIONS.md)</small>.
|
||||
|
@ -11,7 +11,7 @@ use std::process::Command;
|
||||
static BANNER: &str = "// Rust test file autogenerated with cargo build (build/emtests.rs).
|
||||
// Please do NOT modify it by hand, as it will be reseted on next build.\n";
|
||||
|
||||
const TESTS: [&str; 2] = ["emtests/puts.c", "emtests/printf.c"];
|
||||
const TESTS: [&str; 3] = ["emtests/env.c", "emtests/puts.c", "emtests/printf.c"];
|
||||
|
||||
pub fn compile(file: &str) -> String {
|
||||
let mut output_path = PathBuf::from(file);
|
||||
|
@ -1 +0,0 @@
|
||||
Subproject commit cb62a1ead2c5346ccb0f1224ecae5939ac064f87
|
25
emtests/env.c
Normal file
25
emtests/env.c
Normal file
@ -0,0 +1,25 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
int main()
|
||||
{
|
||||
printf("INIT\n");
|
||||
const char* UNEXISTENT_ENVVAR = getenv("UNEXISTENT_ENVVAR");
|
||||
printf("UNEXISTENT_ENVVAR = %s\n",(UNEXISTENT_ENVVAR!=NULL)? UNEXISTENT_ENVVAR : "[NULL]");
|
||||
printf("Setting UNEXISTENT_ENVVAR=PUTENV (via putenv)\n");
|
||||
putenv("UNEXISTENT_ENVVAR=PUTENV");
|
||||
UNEXISTENT_ENVVAR = getenv("UNEXISTENT_ENVVAR");
|
||||
printf("UNEXISTENT_ENVVAR = %s\n",(UNEXISTENT_ENVVAR!=NULL)? UNEXISTENT_ENVVAR : "[NULL]");
|
||||
printf("Setting UNEXISTENT_ENVVAR=SETENV (via setenv, overwrite)\n");
|
||||
setenv("UNEXISTENT_ENVVAR", "SETENV", 1);
|
||||
UNEXISTENT_ENVVAR = getenv("UNEXISTENT_ENVVAR");
|
||||
printf("UNEXISTENT_ENVVAR = %s\n",(UNEXISTENT_ENVVAR!=NULL)? UNEXISTENT_ENVVAR : "[NULL]");
|
||||
printf("Setting UNEXISTENT_ENVVAR=SETENV_NEW (via setenv, NO overwrite)\n");
|
||||
setenv("UNEXISTENT_ENVVAR", "SETENV_NEW", 0);
|
||||
UNEXISTENT_ENVVAR = getenv("UNEXISTENT_ENVVAR");
|
||||
printf("UNEXISTENT_ENVVAR = %s\n",(UNEXISTENT_ENVVAR!=NULL)? UNEXISTENT_ENVVAR : "[NULL]");
|
||||
printf("Unsetting UNEXISTENT_ENVVAR\n");
|
||||
unsetenv("UNEXISTENT_ENVVAR");
|
||||
UNEXISTENT_ENVVAR = getenv("UNEXISTENT_ENVVAR");
|
||||
printf("UNEXISTENT_ENVVAR = %s\n",(UNEXISTENT_ENVVAR!=NULL)? UNEXISTENT_ENVVAR : "[NULL]");
|
||||
printf("END\n");
|
||||
}
|
11
emtests/env.output
Normal file
11
emtests/env.output
Normal file
@ -0,0 +1,11 @@
|
||||
INIT
|
||||
UNEXISTENT_ENVVAR = [NULL]
|
||||
Setting UNEXISTENT_ENVVAR=PUTENV (via putenv)
|
||||
UNEXISTENT_ENVVAR = PUTENV
|
||||
Setting UNEXISTENT_ENVVAR=SETENV (via setenv, overwrite)
|
||||
UNEXISTENT_ENVVAR = SETENV
|
||||
Setting UNEXISTENT_ENVVAR=SETENV_NEW (via setenv, NO overwrite)
|
||||
UNEXISTENT_ENVVAR = SETENV
|
||||
Unsetting UNEXISTENT_ENVVAR
|
||||
UNEXISTENT_ENVVAR = [NULL]
|
||||
END
|
BIN
emtests/env.wasm
Normal file
BIN
emtests/env.wasm
Normal file
Binary file not shown.
Binary file not shown.
BIN
examples/lua.wasm
Normal file
BIN
examples/lua.wasm
Normal file
Binary file not shown.
@ -26,9 +26,21 @@
|
||||
|
||||
###### ENVIRONMENT
|
||||
|
||||
- **\_getenv** [:top:](#host-apis)
|
||||
- **\_getenv** ✅ [:top:](#host-apis)
|
||||
```rust
|
||||
|
||||
fn _getenv(name: c_int, instance: &mut Instance)
|
||||
```
|
||||
- **\_putenv** ✅ [:top:](#host-apis)
|
||||
```rust
|
||||
fn _putenv(name: c_int, instance: &mut Instance)
|
||||
```
|
||||
- **\_setenv** ✅ [:top:](#host-apis)
|
||||
```rust
|
||||
fn _setenv(name: c_int, value: c_int, overwrite: c_int, instance: &mut Instance
|
||||
```
|
||||
- **\_unsetenv** ✅ [:top:](#host-apis)
|
||||
```rust
|
||||
fn _unsetenv(name: c_int, instance: &mut Instance)
|
||||
```
|
||||
|
||||
###### THREAD
|
||||
@ -44,10 +56,6 @@
|
||||
- **\_pthread_setspecific** [:top:](#host-apis)
|
||||
```rust
|
||||
|
||||
```
|
||||
- **\_unsetenv** [:top:](#host-apis)
|
||||
```rust
|
||||
|
||||
```
|
||||
- **\_\_\_lock** [:top:](#host-apis)
|
||||
```rust
|
||||
|
@ -1,26 +1,66 @@
|
||||
use super::super::host;
|
||||
/// NOTE: These syscalls only support wasm_32 for now because they take u32 offset
|
||||
use libc::{c_int, c_long, getgrnam as libc_getgrnam, getpwnam as libc_getpwnam, sysconf};
|
||||
use libc::{
|
||||
c_int, c_long, getenv, getgrnam as libc_getgrnam, getpwnam as libc_getpwnam, putenv, setenv,
|
||||
sysconf, unsetenv,
|
||||
};
|
||||
use std::ffi::CStr;
|
||||
use std::mem;
|
||||
use std::os::raw::c_char;
|
||||
|
||||
use super::utils::{copy_cstr_into_wasm, copy_terminated_array_of_cstrs};
|
||||
use super::utils::{allocate_on_stack, copy_cstr_into_wasm, copy_terminated_array_of_cstrs};
|
||||
use crate::webassembly::Instance;
|
||||
|
||||
/// emscripten: _getenv
|
||||
pub extern "C" fn _getenv(name_ptr: c_int, instance: &mut Instance) -> c_int {
|
||||
debug!("emscripten::_getenv {}", name_ptr);
|
||||
let name = unsafe {
|
||||
let memory_name_ptr = instance.memory_offset_addr(0, name_ptr as usize) as *const c_char;
|
||||
CStr::from_ptr(memory_name_ptr).to_str().unwrap()
|
||||
};
|
||||
match host::get_env(name, instance) {
|
||||
Ok(_) => {
|
||||
unimplemented!();
|
||||
}
|
||||
Err(_) => 0,
|
||||
// #[no_mangle]
|
||||
/// emscripten: _getenv // (name: *const char) -> *const c_char;
|
||||
pub extern "C" fn _getenv(name: c_int, instance: &mut Instance) -> u32 {
|
||||
debug!("emscripten::_getenv");
|
||||
|
||||
let name_addr = instance.memory_offset_addr(0, name as usize) as *const c_char;
|
||||
|
||||
debug!("=> name({:?})", unsafe { CStr::from_ptr(name_addr) });
|
||||
|
||||
let c_str = unsafe { getenv(name_addr) };
|
||||
if c_str.is_null() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsafe { copy_cstr_into_wasm(instance, c_str) }
|
||||
}
|
||||
|
||||
/// emscripten: _setenv // (name: *const char, name: *const value, overwrite: int);
|
||||
pub extern "C" fn _setenv(name: c_int, value: c_int, overwrite: c_int, instance: &mut Instance) {
|
||||
debug!("emscripten::_setenv");
|
||||
|
||||
let name_addr = instance.memory_offset_addr(0, name as usize) as *const c_char;
|
||||
let value_addr = instance.memory_offset_addr(0, value as usize) as *const c_char;
|
||||
|
||||
debug!("=> name({:?})", unsafe { CStr::from_ptr(name_addr) });
|
||||
debug!("=> value({:?})", unsafe { CStr::from_ptr(value_addr) });
|
||||
|
||||
unsafe { setenv(name_addr, value_addr, overwrite) };
|
||||
}
|
||||
|
||||
/// emscripten: _putenv // (name: *const char);
|
||||
pub extern "C" fn _putenv(name: c_int, instance: &mut Instance) {
|
||||
debug!("emscripten::_putenv");
|
||||
|
||||
let name_addr = instance.memory_offset_addr(0, name as usize) as *const c_char;
|
||||
|
||||
debug!("=> name({:?})", unsafe { CStr::from_ptr(name_addr) });
|
||||
|
||||
unsafe { putenv(name_addr as _) };
|
||||
}
|
||||
|
||||
/// emscripten: _unsetenv // (name: *const char);
|
||||
pub extern "C" fn _unsetenv(name: c_int, instance: &mut Instance) {
|
||||
debug!("emscripten::_unsetenv");
|
||||
|
||||
let name_addr = instance.memory_offset_addr(0, name as usize) as *const c_char;
|
||||
|
||||
debug!("=> name({:?})", unsafe { CStr::from_ptr(name_addr) });
|
||||
|
||||
unsafe { unsetenv(name_addr) };
|
||||
}
|
||||
|
||||
pub extern "C" fn _getpwnam(name_ptr: c_int, instance: &mut Instance) -> c_int {
|
||||
@ -102,8 +142,26 @@ pub extern "C" fn _getpagesize() -> u32 {
|
||||
16384
|
||||
}
|
||||
|
||||
pub extern "C" fn ___build_environment(environ: c_int) {
|
||||
pub extern "C" fn ___build_environment(environ: c_int, instance: &mut Instance) {
|
||||
debug!("emscripten::___build_environment {}", environ);
|
||||
const MAX_ENV_VALUES: u32 = 64;
|
||||
const TOTAL_ENV_SIZE: u32 = 1024;
|
||||
let mut environment = instance.memory_offset_addr(0, environ as _) as *mut c_int;
|
||||
unsafe {
|
||||
let (pool_offset, pool_slice): (u32, &mut [u8]) =
|
||||
allocate_on_stack(TOTAL_ENV_SIZE as u32, instance);
|
||||
let (env_offset, env_slice): (u32, &mut [u8]) =
|
||||
allocate_on_stack((MAX_ENV_VALUES * 4) as u32, instance);
|
||||
let mut env_ptr = instance.memory_offset_addr(0, env_offset as _) as *mut c_int;
|
||||
let mut pool_ptr = instance.memory_offset_addr(0, pool_offset as _) as *mut c_int;
|
||||
*env_ptr = pool_offset as i32;
|
||||
*environment = env_offset as i32;
|
||||
|
||||
// *env_ptr = 0;
|
||||
};
|
||||
// unsafe {
|
||||
// *env_ptr = 0;
|
||||
// };
|
||||
}
|
||||
|
||||
pub extern "C" fn _sysconf(name: c_int, _instance: &mut Instance) -> c_long {
|
||||
|
@ -1,7 +1,7 @@
|
||||
// use std::collections::HashMap;
|
||||
|
||||
pub extern "C" fn ___seterrno(value: i32) -> i32 {
|
||||
debug!("emscripten::___seterrno");
|
||||
debug!("emscripten::___seterrno {}", value);
|
||||
// TODO: Incomplete impl
|
||||
eprintln!("failed to set errno!");
|
||||
value
|
||||
|
15
src/apis/emscripten/exception.rs
Normal file
15
src/apis/emscripten/exception.rs
Normal file
@ -0,0 +1,15 @@
|
||||
use super::process::_abort;
|
||||
use crate::webassembly::Instance;
|
||||
|
||||
/// emscripten: ___cxa_allocate_exception
|
||||
pub extern "C" fn ___cxa_allocate_exception(size: u32, instance: &mut Instance) -> u32 {
|
||||
debug!("emscripten::___cxa_allocate_exception");
|
||||
(instance.emscripten_data.as_ref().unwrap().malloc)(size as _, instance)
|
||||
}
|
||||
|
||||
/// emscripten: ___cxa_throw
|
||||
/// TODO: We don't have support for exceptions yet
|
||||
pub extern "C" fn ___cxa_throw(ptr: u32, ty: u32, destructor: u32, instance: &mut Instance) {
|
||||
debug!("emscripten::___cxa_throw");
|
||||
_abort();
|
||||
}
|
@ -7,7 +7,7 @@ pub use libc::putchar;
|
||||
|
||||
/// printf
|
||||
pub extern "C" fn printf(memory_offset: i32, extra: i32, instance: &Instance) -> i32 {
|
||||
debug!("emscripten::printf");
|
||||
debug!("emscripten::printf {}, {}", memory_offset, extra);
|
||||
unsafe {
|
||||
let addr = instance.memory_offset_addr(0, memory_offset as _) as _;
|
||||
_printf(addr, extra)
|
||||
|
41
src/apis/emscripten/jmp.rs
Normal file
41
src/apis/emscripten/jmp.rs
Normal file
@ -0,0 +1,41 @@
|
||||
use crate::webassembly::Instance;
|
||||
use libc::{c_int, c_void};
|
||||
use std::cell::UnsafeCell;
|
||||
|
||||
/// setjmp
|
||||
pub extern "C" fn __setjmp(env_addr: u32, instance: &mut Instance) -> c_int {
|
||||
debug!("emscripten::__setjmp (setjmp)");
|
||||
unsafe {
|
||||
// Rather than using the env as the holder of the jump buffer pointer,
|
||||
// we use the environment address to store the index relative to jumps
|
||||
// so the address of the jump it's outside the wasm memory itself.
|
||||
let jump_index = instance.memory_offset_addr(0, env_addr as usize) as *mut i8;
|
||||
// We create the jump buffer outside of the wasm memory
|
||||
let jump_buf: UnsafeCell<[c_int; 27]> = UnsafeCell::new([0; 27]);
|
||||
let mut jumps = &mut instance.emscripten_data.as_mut().unwrap().jumps;
|
||||
let result = setjmp(jump_buf.get() as _);
|
||||
// We set the jump index to be the last value of jumps
|
||||
*jump_index = jumps.len() as _;
|
||||
// We hold the reference of the jump buffer
|
||||
jumps.push(jump_buf);
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
/// longjmp
|
||||
pub extern "C" fn __longjmp(env_addr: u32, val: c_int, instance: &mut Instance) -> ! {
|
||||
debug!("emscripten::__longjmp (longjmp) {}", val);
|
||||
unsafe {
|
||||
// We retrieve the jump index from the env address
|
||||
let jump_index = instance.memory_offset_addr(0, env_addr as usize) as *mut i8;
|
||||
let mut jumps = &mut instance.emscripten_data.as_mut().unwrap().jumps;
|
||||
// We get the real jump buffer from the jumps vector, using the retrieved index
|
||||
let mut jump_buf = &jumps[*jump_index as usize];
|
||||
longjmp(jump_buf.get() as _, val)
|
||||
};
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
fn setjmp(env: *mut c_void) -> c_int;
|
||||
fn longjmp(env: *mut c_void, val: c_int) -> !;
|
||||
}
|
27
src/apis/emscripten/linking.rs
Normal file
27
src/apis/emscripten/linking.rs
Normal file
@ -0,0 +1,27 @@
|
||||
use crate::webassembly::Instance;
|
||||
|
||||
// TODO: Need to implement.
|
||||
|
||||
/// emscripten: dlopen(filename: *const c_char, flag: c_int) -> *mut c_void
|
||||
pub extern "C" fn _dlopen(filename: u32, flag: c_int) -> u32 {
|
||||
debug!("emscripten::_dlopen");
|
||||
-1
|
||||
}
|
||||
|
||||
/// emscripten: dlclose(handle: *mut c_void) -> c_int
|
||||
pub extern "C" fn _dlclose(filename: u32) -> u32 {
|
||||
debug!("emscripten::_dlclose");
|
||||
-1
|
||||
}
|
||||
|
||||
/// emscripten: dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void
|
||||
pub extern "C" fn _dlsym(filepath: u32, symbol: u32) -> u32 {
|
||||
debug!("emscripten::_dlerror");
|
||||
-1
|
||||
}
|
||||
|
||||
/// emscripten: dlerror() -> *mut c_char
|
||||
pub extern "C" fn _dlerror() -> u32 {
|
||||
debug!("emscripten::_dlerror");
|
||||
-1
|
||||
}
|
@ -2,11 +2,16 @@ use crate::webassembly::Instance;
|
||||
use libc::c_int;
|
||||
|
||||
// NOTE: Not implemented by Emscripten
|
||||
pub extern "C" fn ___lock(_which: c_int, _varargs: c_int, _instance: &mut Instance) {
|
||||
debug!("emscripten::___lock");
|
||||
pub extern "C" fn ___lock(which: c_int, varargs: c_int, _instance: &mut Instance) {
|
||||
debug!("emscripten::___lock {}, {}", which, varargs);
|
||||
}
|
||||
|
||||
// NOTE: Not implemented by Emscripten
|
||||
pub extern "C" fn ___unlock(_which: c_int, _varargs: c_int, _instance: &mut Instance) {
|
||||
debug!("emscripten::___unlock");
|
||||
pub extern "C" fn ___unlock(which: c_int, varargs: c_int, _instance: &mut Instance) {
|
||||
debug!("emscripten::___unlock {}, {}", which, varargs);
|
||||
}
|
||||
|
||||
// NOTE: Not implemented by Emscripten
|
||||
pub extern "C" fn ___wait(_which: c_int, _varargs: c_int, _instance: &mut Instance) {
|
||||
debug!("emscripten::___wait");
|
||||
}
|
||||
|
19
src/apis/emscripten/math.rs
Normal file
19
src/apis/emscripten/math.rs
Normal file
@ -0,0 +1,19 @@
|
||||
use crate::webassembly::Instance;
|
||||
|
||||
/// emscripten: _llvm_log10_f64
|
||||
pub extern "C" fn _llvm_log10_f64(value: f64) -> f64 {
|
||||
debug!("emscripten::_llvm_log10_f64");
|
||||
value.log10()
|
||||
}
|
||||
|
||||
/// emscripten: _llvm_log2_f64
|
||||
pub extern "C" fn _llvm_log2_f64(value: f64) -> f64 {
|
||||
debug!("emscripten::_llvm_log2_f64");
|
||||
value.log2()
|
||||
}
|
||||
|
||||
// emscripten: f64-rem
|
||||
pub extern "C" fn f64_rem(x: f64, y: f64) -> f64 {
|
||||
debug!("emscripten::f64-rem");
|
||||
x % y
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
use super::process::abort_with_message;
|
||||
use crate::webassembly::Instance;
|
||||
use libc::{c_void, memcpy, size_t};
|
||||
use libc::{c_int, c_void, memcpy, size_t};
|
||||
|
||||
/// emscripten: _emscripten_memcpy_big
|
||||
pub extern "C" fn _emscripten_memcpy_big(
|
||||
@ -9,7 +9,10 @@ pub extern "C" fn _emscripten_memcpy_big(
|
||||
len: u32,
|
||||
instance: &mut Instance,
|
||||
) -> u32 {
|
||||
debug!("emscripten::_emscripten_memcpy_big");
|
||||
debug!(
|
||||
"emscripten::_emscripten_memcpy_big {}, {}, {}",
|
||||
dest, src, len
|
||||
);
|
||||
let dest_addr = instance.memory_offset_addr(0, dest as usize) as *mut c_void;
|
||||
let src_addr = instance.memory_offset_addr(0, src as usize) as *mut c_void;
|
||||
unsafe {
|
||||
@ -36,3 +39,10 @@ pub extern "C" fn abort_on_cannot_grow_memory() {
|
||||
debug!("emscripten::abort_on_cannot_grow_memory");
|
||||
abort_with_message("Cannot enlarge memory arrays!");
|
||||
}
|
||||
|
||||
/// emscripten: ___map_file
|
||||
pub extern "C" fn ___map_file() -> c_int {
|
||||
debug!("emscripten::___map_file");
|
||||
// NOTE: TODO: Em returns -1 here as well. May need to implement properly
|
||||
-1
|
||||
}
|
||||
|
@ -6,8 +6,11 @@ use std::mem;
|
||||
// EMSCRIPTEN APIS
|
||||
mod env;
|
||||
mod errno;
|
||||
mod exception;
|
||||
mod io;
|
||||
mod jmp;
|
||||
mod lock;
|
||||
mod math;
|
||||
mod memory;
|
||||
mod nullfunc;
|
||||
mod process;
|
||||
@ -108,8 +111,12 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
|
||||
// Lock
|
||||
import_object.set("env", "___lock", ImportValue::Func(lock::___lock as _));
|
||||
import_object.set("env", "___unlock", ImportValue::Func(lock::___unlock as _));
|
||||
import_object.set("env", "___wait", ImportValue::Func(lock::___wait as _));
|
||||
// Env
|
||||
import_object.set("env", "_getenv", ImportValue::Func(env::_getenv as _));
|
||||
import_object.set("env", "_setenv", ImportValue::Func(env::_setenv as _));
|
||||
import_object.set("env", "_putenv", ImportValue::Func(env::_putenv as _));
|
||||
import_object.set("env", "_unsetenv", ImportValue::Func(env::_unsetenv as _));
|
||||
import_object.set("env", "_getpwnam", ImportValue::Func(env::_getpwnam as _));
|
||||
import_object.set("env", "_getgrnam", ImportValue::Func(env::_getgrnam as _));
|
||||
import_object.set(
|
||||
@ -149,16 +156,71 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
|
||||
"___syscall6",
|
||||
ImportValue::Func(syscalls::___syscall6 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall12",
|
||||
ImportValue::Func(syscalls::___syscall12 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall20",
|
||||
ImportValue::Func(syscalls::___syscall20 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall39",
|
||||
ImportValue::Func(syscalls::___syscall39 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall40",
|
||||
ImportValue::Func(syscalls::___syscall40 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall54",
|
||||
ImportValue::Func(syscalls::___syscall54 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall57",
|
||||
ImportValue::Func(syscalls::___syscall57 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall63",
|
||||
ImportValue::Func(syscalls::___syscall63 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall64",
|
||||
ImportValue::Func(syscalls::___syscall64 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall102",
|
||||
ImportValue::Func(syscalls::___syscall102 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall114",
|
||||
ImportValue::Func(syscalls::___syscall114 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall122",
|
||||
ImportValue::Func(syscalls::___syscall122 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall140",
|
||||
ImportValue::Func(syscalls::___syscall140 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall142",
|
||||
ImportValue::Func(syscalls::___syscall142 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall145",
|
||||
@ -171,23 +233,28 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall221",
|
||||
ImportValue::Func(syscalls::___syscall221 as _),
|
||||
"___syscall180",
|
||||
ImportValue::Func(syscalls::___syscall180 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall20",
|
||||
ImportValue::Func(syscalls::___syscall20 as _),
|
||||
"___syscall181",
|
||||
ImportValue::Func(syscalls::___syscall181 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall64",
|
||||
ImportValue::Func(syscalls::___syscall64 as _),
|
||||
"___syscall192",
|
||||
ImportValue::Func(syscalls::___syscall192 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall122",
|
||||
ImportValue::Func(syscalls::___syscall122 as _),
|
||||
"___syscall195",
|
||||
ImportValue::Func(syscalls::___syscall195 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall197",
|
||||
ImportValue::Func(syscalls::___syscall197 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
@ -199,36 +266,6 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
|
||||
"___syscall202",
|
||||
ImportValue::Func(syscalls::___syscall202 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall340",
|
||||
ImportValue::Func(syscalls::___syscall340 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall197",
|
||||
ImportValue::Func(syscalls::___syscall197 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall180",
|
||||
ImportValue::Func(syscalls::___syscall180 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall181",
|
||||
ImportValue::Func(syscalls::___syscall181 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall39",
|
||||
ImportValue::Func(syscalls::___syscall39 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall195",
|
||||
ImportValue::Func(syscalls::___syscall195 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall212",
|
||||
@ -241,40 +278,14 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall102",
|
||||
ImportValue::Func(syscalls::___syscall102 as _),
|
||||
"___syscall330",
|
||||
ImportValue::Func(syscalls::___syscall330 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall54",
|
||||
ImportValue::Func(syscalls::___syscall54 as _),
|
||||
"___syscall340",
|
||||
ImportValue::Func(syscalls::___syscall340 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall12",
|
||||
ImportValue::Func(syscalls::___syscall12 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall192",
|
||||
ImportValue::Func(syscalls::___syscall192 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall63",
|
||||
ImportValue::Func(syscalls::___syscall63 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall142",
|
||||
ImportValue::Func(syscalls::___syscall142 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___syscall57",
|
||||
ImportValue::Func(syscalls::___syscall57 as _),
|
||||
);
|
||||
|
||||
// Process
|
||||
import_object.set("env", "abort", ImportValue::Func(process::em_abort as _));
|
||||
import_object.set("env", "_abort", ImportValue::Func(process::_abort as _));
|
||||
@ -283,9 +294,15 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
|
||||
"abortStackOverflow",
|
||||
ImportValue::Func(process::abort_stack_overflow as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"_llvm_trap",
|
||||
ImportValue::Func(process::_llvm_trap as _),
|
||||
);
|
||||
import_object.set("env", "_fork", ImportValue::Func(process::_fork as _));
|
||||
import_object.set("env", "_exit", ImportValue::Func(process::_exit as _));
|
||||
|
||||
import_object.set("env", "_system", ImportValue::Func(process::_system as _));
|
||||
import_object.set("env", "_popen", ImportValue::Func(process::_popen as _));
|
||||
// Signal
|
||||
import_object.set(
|
||||
"env",
|
||||
@ -329,6 +346,27 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
|
||||
"getTotalMemory",
|
||||
ImportValue::Func(memory::get_total_memory as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___map_file",
|
||||
ImportValue::Func(memory::___map_file as _),
|
||||
);
|
||||
// Exception
|
||||
import_object.set(
|
||||
"env",
|
||||
"___cxa_allocate_exception",
|
||||
ImportValue::Func(exception::___cxa_allocate_exception as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___cxa_allocate_exception",
|
||||
ImportValue::Func(exception::___cxa_throw as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___cxa_throw",
|
||||
ImportValue::Func(exception::___cxa_throw as _),
|
||||
);
|
||||
// NullFuncs
|
||||
import_object.set(
|
||||
"env",
|
||||
@ -355,6 +393,11 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
|
||||
"nullFunc_iiiiii",
|
||||
ImportValue::Func(nullfunc::nullfunc_iiiiii as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"nullFunc_v",
|
||||
ImportValue::Func(nullfunc::nullfunc_v as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"nullFunc_vi",
|
||||
@ -375,6 +418,16 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
|
||||
"nullFunc_viiii",
|
||||
ImportValue::Func(nullfunc::nullfunc_viiii as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"nullFunc_viiiii",
|
||||
ImportValue::Func(nullfunc::nullfunc_viiiii as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"nullFunc_viiiiii",
|
||||
ImportValue::Func(nullfunc::nullfunc_viiiiii as _),
|
||||
);
|
||||
// Time
|
||||
import_object.set(
|
||||
"env",
|
||||
@ -386,6 +439,13 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
|
||||
"_clock_gettime",
|
||||
ImportValue::Func(time::_clock_gettime as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"___clock_gettime",
|
||||
ImportValue::Func(time::___clock_gettime as _),
|
||||
);
|
||||
import_object.set("env", "_clock", ImportValue::Func(time::_clock as _));
|
||||
import_object.set("env", "_difftime", ImportValue::Func(time::_difftime as _));
|
||||
import_object.set("env", "_asctime", ImportValue::Func(time::_asctime as _));
|
||||
import_object.set(
|
||||
"env",
|
||||
@ -410,6 +470,21 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
|
||||
ImportValue::Func(env::_getpagesize as _),
|
||||
);
|
||||
import_object.set("env", "_sysconf", ImportValue::Func(env::_sysconf as _));
|
||||
// Math
|
||||
import_object.set(
|
||||
"env",
|
||||
"_llvm_log10_f64",
|
||||
ImportValue::Func(math::_llvm_log10_f64 as _),
|
||||
);
|
||||
import_object.set(
|
||||
"env",
|
||||
"_llvm_log2_f64",
|
||||
ImportValue::Func(math::_llvm_log2_f64 as _),
|
||||
);
|
||||
import_object.set("asm2wasm", "f64-rem", ImportValue::Func(math::f64_rem as _));
|
||||
|
||||
import_object.set("env", "__setjmp", ImportValue::Func(jmp::__setjmp as _));
|
||||
import_object.set("env", "__longjmp", ImportValue::Func(jmp::__longjmp as _));
|
||||
|
||||
mock_external!(import_object, _waitpid);
|
||||
mock_external!(import_object, _utimes);
|
||||
@ -453,7 +528,7 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
|
||||
mock_external!(import_object, ___syscall66);
|
||||
// mock_external!(import_object, ___syscall64);
|
||||
// mock_external!(import_object, ___syscall63);
|
||||
mock_external!(import_object, ___syscall60);
|
||||
// mock_external!(import_object, ___syscall60);
|
||||
// mock_external!(import_object, ___syscall54);
|
||||
// mock_external!(import_object, ___syscall39);
|
||||
mock_external!(import_object, ___syscall38);
|
||||
@ -485,6 +560,10 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
|
||||
// mock_external!(import_object, ___syscall20);
|
||||
mock_external!(import_object, ___syscall15);
|
||||
mock_external!(import_object, ___syscall10);
|
||||
mock_external!(import_object, _dlopen);
|
||||
mock_external!(import_object, _dlclose);
|
||||
mock_external!(import_object, _dlsym);
|
||||
mock_external!(import_object, _dlerror);
|
||||
|
||||
import_object
|
||||
}
|
||||
|
@ -1,47 +1,62 @@
|
||||
use super::process::abort_with_message;
|
||||
use crate::webassembly::Instance;
|
||||
|
||||
pub extern "C" fn nullfunc_ii(_x: u32, _instance: &Instance) {
|
||||
debug!("emscripten::nullfunc_ii");
|
||||
pub extern "C" fn nullfunc_ii(x: u32, _instance: &Instance) {
|
||||
debug!("emscripten::nullfunc_ii {}", x);
|
||||
abort_with_message("Invalid function pointer called with signature 'ii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)");
|
||||
}
|
||||
|
||||
pub extern "C" fn nullfunc_iii(_x: u32, _instance: &Instance) {
|
||||
debug!("emscripten::nullfunc_iii");
|
||||
pub extern "C" fn nullfunc_iii(x: u32, _instance: &Instance) {
|
||||
debug!("emscripten::nullfunc_iii {}", x);
|
||||
abort_with_message("Invalid function pointer called with signature 'iii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)");
|
||||
}
|
||||
|
||||
pub extern "C" fn nullfunc_iiii(_x: u32, _instance: &Instance) {
|
||||
debug!("emscripten::nullfunc_iiii");
|
||||
pub extern "C" fn nullfunc_iiii(x: u32, _instance: &Instance) {
|
||||
debug!("emscripten::nullfunc_iiii {}", x);
|
||||
abort_with_message("Invalid function pointer called with signature 'iiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)");
|
||||
}
|
||||
|
||||
pub extern "C" fn nullfunc_iiiii(_x: u32, _instance: &Instance) {
|
||||
debug!("emscripten::nullfunc_iiiii");
|
||||
pub extern "C" fn nullfunc_iiiii(x: u32, _instance: &Instance) {
|
||||
debug!("emscripten::nullfunc_iiiii {}", x);
|
||||
abort_with_message("Invalid function pointer called with signature 'iiiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)");
|
||||
}
|
||||
|
||||
pub extern "C" fn nullfunc_iiiiii(_x: u32, _instance: &Instance) {
|
||||
debug!("emscripten::nullfunc_iiiiii");
|
||||
pub extern "C" fn nullfunc_iiiiii(x: u32, _instance: &Instance) {
|
||||
debug!("emscripten::nullfunc_iiiiii {}", x);
|
||||
abort_with_message("Invalid function pointer called with signature 'iiiiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)");
|
||||
}
|
||||
|
||||
pub extern "C" fn nullfunc_vi(_x: u32, _instance: &Instance) {
|
||||
debug!("emscripten::nullfunc_vi");
|
||||
pub extern "C" fn nullfunc_v(x: u32, _instance: &Instance) {
|
||||
debug!("emscripten::nullfunc_v {}", x);
|
||||
abort_with_message("Invalid function pointer called with signature 'v'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)");
|
||||
}
|
||||
|
||||
pub extern "C" fn nullfunc_vi(x: u32, _instance: &Instance) {
|
||||
debug!("emscripten::nullfunc_vi {}", x);
|
||||
abort_with_message("Invalid function pointer called with signature 'vi'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)");
|
||||
}
|
||||
|
||||
pub extern "C" fn nullfunc_vii(_x: u32, _instance: &Instance) {
|
||||
debug!("emscripten::nullfunc_vii");
|
||||
pub extern "C" fn nullfunc_vii(x: u32, _instance: &Instance) {
|
||||
debug!("emscripten::nullfunc_vii {}", x);
|
||||
abort_with_message("Invalid function pointer called with signature 'vii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)");
|
||||
}
|
||||
|
||||
pub extern "C" fn nullfunc_viii(_x: u32, _instance: &Instance) {
|
||||
debug!("emscripten::nullfunc_viii");
|
||||
pub extern "C" fn nullfunc_viii(x: u32, _instance: &Instance) {
|
||||
debug!("emscripten::nullfunc_viii {}", x);
|
||||
abort_with_message("Invalid function pointer called with signature 'viii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)");
|
||||
}
|
||||
|
||||
pub extern "C" fn nullfunc_viiii(_x: u32, _instance: &Instance) {
|
||||
debug!("emscripten::nullfunc_viiii");
|
||||
pub extern "C" fn nullfunc_viiii(x: u32, _instance: &Instance) {
|
||||
debug!("emscripten::nullfunc_viiii {}", x);
|
||||
abort_with_message("Invalid function pointer called with signature 'viiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)");
|
||||
}
|
||||
|
||||
pub extern "C" fn nullfunc_viiiii(_x: u32, _instance: &Instance) {
|
||||
debug!("emscripten::nullfunc_viiiii");
|
||||
abort_with_message("Invalid function pointer called with signature 'viiiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)");
|
||||
}
|
||||
|
||||
pub extern "C" fn nullfunc_viiiiii(_x: u32, _instance: &Instance) {
|
||||
debug!("emscripten::nullfunc_viiiiii");
|
||||
abort_with_message("Invalid function pointer called with signature 'viiiiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)");
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use libc::{abort, c_char, c_int, exit, pid_t};
|
||||
use libc::{abort, c_char, c_int, exit, pid_t, EAGAIN};
|
||||
|
||||
use crate::webassembly::Instance;
|
||||
use std::ffi::CStr;
|
||||
@ -25,12 +25,12 @@ pub extern "C" fn _fork(_instance: &mut Instance) -> pid_t {
|
||||
}
|
||||
|
||||
pub extern "C" fn _exit(status: c_int, _instance: &mut Instance) -> ! {
|
||||
debug!("emscripten::_exit");
|
||||
debug!("emscripten::_exit {}", status);
|
||||
unsafe { exit(status) }
|
||||
}
|
||||
|
||||
pub extern "C" fn em_abort(message: u32, instance: &mut Instance) {
|
||||
debug!("emscripten::em_abort");
|
||||
debug!("emscripten::em_abort {}", message);
|
||||
let message_addr = instance.memory_offset_addr(0, message as usize) as *mut c_char;
|
||||
unsafe {
|
||||
let message = CStr::from_ptr(message_addr)
|
||||
@ -46,3 +46,24 @@ pub extern "C" fn abort_stack_overflow() {
|
||||
// TODO: Message incomplete. Need to finish em runtime data first
|
||||
abort_with_message("Stack overflow! Attempted to allocate some bytes on the stack");
|
||||
}
|
||||
|
||||
pub extern "C" fn _llvm_trap() {
|
||||
debug!("emscripten::_llvm_trap");
|
||||
abort_with_message("abort!");
|
||||
}
|
||||
|
||||
pub extern "C" fn _system() -> c_int {
|
||||
debug!("emscripten::_system");
|
||||
// TODO: May need to change this Em impl to a working version
|
||||
eprintln!("Can't call external programs");
|
||||
return EAGAIN;
|
||||
}
|
||||
|
||||
pub extern "C" fn _popen() -> c_int {
|
||||
debug!("emscripten::_popen");
|
||||
// TODO: May need to change this Em impl to a working version
|
||||
eprintln!("Missing function: popen");
|
||||
unsafe {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
@ -10,18 +10,13 @@ pub extern "C" fn _sigemptyset(set: u32, instance: &mut Instance) -> i32 {
|
||||
0
|
||||
}
|
||||
|
||||
pub extern "C" fn _sigaction(
|
||||
_signum: u32,
|
||||
_act: u32,
|
||||
_oldact: u32,
|
||||
_instance: &mut Instance,
|
||||
) -> i32 {
|
||||
debug!("emscripten::_sigaction");
|
||||
pub extern "C" fn _sigaction(signum: u32, act: u32, oldact: u32, _instance: &mut Instance) -> i32 {
|
||||
debug!("emscripten::_sigaction {}, {}, {}", signum, act, oldact);
|
||||
0
|
||||
}
|
||||
|
||||
pub extern "C" fn _sigaddset(set: u32, signum: u32, instance: &mut Instance) -> i32 {
|
||||
debug!("emscripten::_sigaddset");
|
||||
debug!("emscripten::_sigaddset {}, {}", set, signum);
|
||||
let set_addr = instance.memory_offset_addr(0, set as _) as *mut u32;
|
||||
unsafe {
|
||||
*set_addr |= 1 << (signum - 1);
|
||||
|
@ -18,6 +18,7 @@ use libc::{
|
||||
connect,
|
||||
dup2,
|
||||
exit,
|
||||
fcntl,
|
||||
fstat,
|
||||
getgid,
|
||||
getpeername,
|
||||
@ -42,6 +43,9 @@ use libc::{
|
||||
// readv,
|
||||
recvfrom,
|
||||
recvmsg,
|
||||
rmdir,
|
||||
// ENOTTY,
|
||||
rusage,
|
||||
sa_family_t,
|
||||
// writev,
|
||||
select,
|
||||
@ -57,16 +61,30 @@ use libc::{
|
||||
uname,
|
||||
utsname,
|
||||
write,
|
||||
EINVAL,
|
||||
// sockaddr_in,
|
||||
FIOCLEX,
|
||||
FIONBIO,
|
||||
F_GETFD,
|
||||
F_SETFD,
|
||||
SOL_SOCKET,
|
||||
TIOCGWINSZ,
|
||||
};
|
||||
|
||||
use std::mem;
|
||||
use std::slice;
|
||||
// use std::sys::fd::FileDesc;
|
||||
|
||||
// Linking to functions that are not provided by rust libc
|
||||
#[cfg(target_os = "macos")]
|
||||
#[link(name = "c")]
|
||||
extern "C" {
|
||||
pub fn wait4(pid: pid_t, status: *mut c_int, options: c_int, rusage: *mut rusage) -> pid_t;
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
use libc::wait4;
|
||||
|
||||
// Another conditional constant for name resolution: Macos et iOS use
|
||||
// SO_NOSIGPIPE as a setsockopt flag to disable SIGPIPE emission on socket.
|
||||
// Other platforms do otherwise.
|
||||
@ -76,8 +94,8 @@ use libc::SO_NOSIGPIPE;
|
||||
const SO_NOSIGPIPE: c_int = 0;
|
||||
|
||||
/// exit
|
||||
pub extern "C" fn ___syscall1(_which: c_int, mut varargs: VarArgs, instance: &mut Instance) {
|
||||
debug!("emscripten::___syscall1 (exit)");
|
||||
pub extern "C" fn ___syscall1(which: c_int, mut varargs: VarArgs, instance: &mut Instance) {
|
||||
debug!("emscripten::___syscall1 (exit) {}", which);
|
||||
let status: i32 = varargs.get(instance);
|
||||
unsafe {
|
||||
exit(status);
|
||||
@ -86,11 +104,11 @@ pub extern "C" fn ___syscall1(_which: c_int, mut varargs: VarArgs, instance: &mu
|
||||
|
||||
/// read
|
||||
pub extern "C" fn ___syscall3(
|
||||
_which: c_int,
|
||||
which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> ssize_t {
|
||||
debug!("emscripten::___syscall3 (read)");
|
||||
debug!("emscripten::___syscall3 (read) {}", which);
|
||||
let fd: i32 = varargs.get(instance);
|
||||
let buf: u32 = varargs.get(instance);
|
||||
let count: usize = varargs.get(instance);
|
||||
@ -103,11 +121,11 @@ pub extern "C" fn ___syscall3(
|
||||
|
||||
/// write
|
||||
pub extern "C" fn ___syscall4(
|
||||
_which: c_int,
|
||||
which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> c_int {
|
||||
debug!("emscripten::___syscall4 (write)");
|
||||
debug!("emscripten::___syscall4 (write) {}", which);
|
||||
let fd: i32 = varargs.get(instance);
|
||||
let buf: u32 = varargs.get(instance);
|
||||
let count: u32 = varargs.get(instance);
|
||||
@ -118,11 +136,11 @@ pub extern "C" fn ___syscall4(
|
||||
|
||||
/// open
|
||||
pub extern "C" fn ___syscall5(
|
||||
_which: c_int,
|
||||
which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> c_int {
|
||||
debug!("emscripten::___syscall5 (open)");
|
||||
debug!("emscripten::___syscall5 (open) {}", which);
|
||||
let pathname: u32 = varargs.get(instance);
|
||||
let flags: i32 = varargs.get(instance);
|
||||
let mode: u32 = varargs.get(instance);
|
||||
@ -138,11 +156,11 @@ pub extern "C" fn ___syscall5(
|
||||
|
||||
/// close
|
||||
pub extern "C" fn ___syscall6(
|
||||
_which: c_int,
|
||||
which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> c_int {
|
||||
debug!("emscripten::___syscall6 (close)");
|
||||
debug!("emscripten::___syscall6 (close) {}", which);
|
||||
let fd: i32 = varargs.get(instance);
|
||||
debug!("fd: {}", fd);
|
||||
unsafe { close(fd) }
|
||||
@ -150,11 +168,11 @@ pub extern "C" fn ___syscall6(
|
||||
|
||||
// chdir
|
||||
pub extern "C" fn ___syscall12(
|
||||
_which: c_int,
|
||||
which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> c_int {
|
||||
debug!("emscripten::___syscall12 (chdir)");
|
||||
debug!("emscripten::___syscall12 (chdir) {}", which);
|
||||
let path_addr: i32 = varargs.get(instance);
|
||||
unsafe {
|
||||
let path_ptr = instance.memory_offset_addr(0, path_addr as usize) as *const i8;
|
||||
@ -173,32 +191,36 @@ pub extern "C" fn ___syscall20() -> pid_t {
|
||||
|
||||
// mkdir
|
||||
pub extern "C" fn ___syscall39(
|
||||
which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> c_int {
|
||||
debug!("emscripten::___syscall39 (mkdir) {}", which);
|
||||
let pathname: u32 = varargs.get(instance);
|
||||
let mode: u32 = varargs.get(instance);
|
||||
let pathname_addr = instance.memory_offset_addr(0, pathname as usize) as *const i8;
|
||||
unsafe { mkdir(pathname_addr, mode as _) }
|
||||
}
|
||||
|
||||
// rmdir
|
||||
pub extern "C" fn ___syscall40(
|
||||
_which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> c_int {
|
||||
debug!("emscripten::___syscall39 (mkdir)");
|
||||
debug!("emscripten::___syscall40 (rmdir)");
|
||||
let pathname: u32 = varargs.get(instance);
|
||||
let mode: u32 = varargs.get(instance);
|
||||
let pathname_addr = instance.memory_offset_addr(0, pathname as usize) as *const i8;
|
||||
|
||||
unsafe { mkdir(pathname_addr, mode as _) };
|
||||
0
|
||||
}
|
||||
|
||||
// getppid
|
||||
pub extern "C" fn ___syscall64() -> pid_t {
|
||||
debug!("emscripten::___syscall64 (getppid)");
|
||||
unsafe { getpid() }
|
||||
unsafe { rmdir(pathname_addr) }
|
||||
}
|
||||
|
||||
/// ioctl
|
||||
pub extern "C" fn ___syscall54(
|
||||
_which: c_int,
|
||||
which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> c_int {
|
||||
debug!("emscripten::___syscall54 (ioctl)");
|
||||
debug!("emscripten::___syscall54 (ioctl) {}", which);
|
||||
let fd: i32 = varargs.get(instance);
|
||||
let request: u32 = varargs.get(instance);
|
||||
debug!("fd: {}, op: {}", fd, request);
|
||||
@ -238,13 +260,45 @@ pub extern "C" fn ___syscall54(
|
||||
}
|
||||
}
|
||||
|
||||
// socketcall
|
||||
pub extern "C" fn ___syscall102(
|
||||
_which: c_int,
|
||||
// setpgid
|
||||
pub extern "C" fn ___syscall57(
|
||||
which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> c_int {
|
||||
debug!("emscripten::___syscall102 (socketcall)");
|
||||
debug!("emscripten::___syscall57 (setpgid) {}", which);
|
||||
let pid: i32 = varargs.get(instance);
|
||||
let pgid: i32 = varargs.get(instance);
|
||||
unsafe { setpgid(pid, pgid) }
|
||||
}
|
||||
|
||||
// dup2
|
||||
pub extern "C" fn ___syscall63(
|
||||
which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> c_int {
|
||||
debug!("emscripten::___syscall63 (dup2) {}", which);
|
||||
|
||||
let src: i32 = varargs.get(instance);
|
||||
let dst: i32 = varargs.get(instance);
|
||||
|
||||
unsafe { dup2(src, dst) }
|
||||
}
|
||||
|
||||
// getppid
|
||||
pub extern "C" fn ___syscall64() -> pid_t {
|
||||
debug!("emscripten::___syscall64 (getppid)");
|
||||
unsafe { getpid() }
|
||||
}
|
||||
|
||||
// socketcall
|
||||
pub extern "C" fn ___syscall102(
|
||||
which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> c_int {
|
||||
debug!("emscripten::___syscall102 (socketcall) {}", which);
|
||||
let call: u32 = varargs.get(instance);
|
||||
let mut socket_varargs: VarArgs = varargs.get(instance);
|
||||
|
||||
@ -515,27 +569,71 @@ pub extern "C" fn ___syscall102(
|
||||
}
|
||||
}
|
||||
|
||||
/// uname
|
||||
// NOTE: Wondering if we should return custom utsname, like Emscripten.
|
||||
pub extern "C" fn ___syscall122(
|
||||
/// wait4
|
||||
pub extern "C" fn ___syscall114(
|
||||
_which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> pid_t {
|
||||
debug!("emscripten::___syscall114 (wait4)");
|
||||
let pid: pid_t = varargs.get(instance);
|
||||
let status: u32 = varargs.get(instance);
|
||||
let options: c_int = varargs.get(instance);
|
||||
let rusage: u32 = varargs.get(instance);
|
||||
let status_addr = instance.memory_offset_addr(0, status as usize) as *mut c_int;
|
||||
let rusage_addr = instance.memory_offset_addr(0, rusage as usize) as *mut rusage;
|
||||
let res = unsafe { wait4(pid, status_addr, options, rusage_addr) };
|
||||
debug!(
|
||||
"=> pid: {}, status: {:?}, options: {}, rusage: {:?} = pid: {}",
|
||||
pid, status_addr, options, rusage_addr, res
|
||||
);
|
||||
res
|
||||
}
|
||||
|
||||
/// uname
|
||||
// NOTE: Wondering if we should return custom utsname, like Emscripten.
|
||||
pub extern "C" fn ___syscall122(
|
||||
which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> c_int {
|
||||
debug!("emscripten::___syscall122 (uname)");
|
||||
debug!("emscripten::___syscall122 (uname) {}", which);
|
||||
let buf: u32 = varargs.get(instance);
|
||||
debug!("=> buf: {}", buf);
|
||||
let buf_addr = instance.memory_offset_addr(0, buf as usize) as *mut utsname;
|
||||
unsafe { uname(buf_addr) }
|
||||
}
|
||||
|
||||
// mmap2
|
||||
pub extern "C" fn ___syscall192(
|
||||
_which: c_int,
|
||||
// select
|
||||
pub extern "C" fn ___syscall142(
|
||||
which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> c_int {
|
||||
debug!("emscripten::___syscall192 (mmap2)");
|
||||
debug!("emscripten::___syscall142 (newselect) {}", which);
|
||||
|
||||
let nfds: i32 = varargs.get(instance);
|
||||
let readfds: u32 = varargs.get(instance);
|
||||
let writefds: u32 = varargs.get(instance);
|
||||
let exceptfds: u32 = varargs.get(instance);
|
||||
let _timeout: i32 = varargs.get(instance);
|
||||
|
||||
assert!(nfds <= 64, "`nfds` must be less than or equal to 64");
|
||||
assert!(exceptfds == 0, "`exceptfds` is not supporrted");
|
||||
|
||||
let readfds_ptr = instance.memory_offset_addr(0, readfds as _) as _;
|
||||
let writefds_ptr = instance.memory_offset_addr(0, writefds as _) as _;
|
||||
|
||||
unsafe { select(nfds, readfds_ptr, writefds_ptr, 0 as _, 0 as _) }
|
||||
}
|
||||
|
||||
// mmap2
|
||||
pub extern "C" fn ___syscall192(
|
||||
which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> c_int {
|
||||
debug!("emscripten::___syscall192 (mmap2) {}", which);
|
||||
let addr: i32 = varargs.get(instance);
|
||||
let len: u32 = varargs.get(instance);
|
||||
let prot: i32 = varargs.get(instance);
|
||||
@ -566,11 +664,11 @@ pub extern "C" fn ___syscall192(
|
||||
|
||||
/// lseek
|
||||
pub extern "C" fn ___syscall140(
|
||||
_which: c_int,
|
||||
which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> off_t {
|
||||
debug!("emscripten::___syscall140 (lseek)");
|
||||
debug!("emscripten::___syscall140 (lseek) {}", which);
|
||||
let fd: i32 = varargs.get(instance);
|
||||
let offset: i64 = varargs.get(instance);
|
||||
let whence: i32 = varargs.get(instance);
|
||||
@ -580,11 +678,11 @@ pub extern "C" fn ___syscall140(
|
||||
|
||||
/// readv
|
||||
pub extern "C" fn ___syscall145(
|
||||
_which: c_int,
|
||||
which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> ssize_t {
|
||||
debug!("emscripten::___syscall145 (readv)");
|
||||
debug!("emscripten::___syscall145 (readv) {}", which);
|
||||
// let fd: i32 = varargs.get(instance);
|
||||
// let iov: u32 = varargs.get(instance);
|
||||
// let iovcnt: i32 = varargs.get(instance);
|
||||
@ -625,11 +723,11 @@ pub extern "C" fn ___syscall145(
|
||||
|
||||
// writev
|
||||
pub extern "C" fn ___syscall146(
|
||||
_which: c_int,
|
||||
which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> ssize_t {
|
||||
debug!("emscripten::___syscall146 (writev)");
|
||||
debug!("emscripten::___syscall146 (writev) {}", which);
|
||||
let fd: i32 = varargs.get(instance);
|
||||
let iov: i32 = varargs.get(instance);
|
||||
let iovcnt: i32 = varargs.get(instance);
|
||||
@ -663,11 +761,11 @@ pub extern "C" fn ___syscall146(
|
||||
|
||||
// pread
|
||||
pub extern "C" fn ___syscall180(
|
||||
_which: c_int,
|
||||
which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> c_int {
|
||||
debug!("emscripten::___syscall180 (pread)");
|
||||
debug!("emscripten::___syscall180 (pread) {}", which);
|
||||
let fd: i32 = varargs.get(instance);
|
||||
let buf: u32 = varargs.get(instance);
|
||||
let count: u32 = varargs.get(instance);
|
||||
@ -684,11 +782,11 @@ pub extern "C" fn ___syscall180(
|
||||
|
||||
// pwrite
|
||||
pub extern "C" fn ___syscall181(
|
||||
_which: c_int,
|
||||
which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> c_int {
|
||||
debug!("emscripten::___syscall181 (pwrite)");
|
||||
debug!("emscripten::___syscall181 (pwrite) {}", which);
|
||||
let fd: i32 = varargs.get(instance);
|
||||
let buf: u32 = varargs.get(instance);
|
||||
let count: u32 = varargs.get(instance);
|
||||
@ -709,11 +807,11 @@ pub extern "C" fn ___syscall181(
|
||||
|
||||
// stat64
|
||||
pub extern "C" fn ___syscall195(
|
||||
_which: c_int,
|
||||
which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> c_int {
|
||||
debug!("emscripten::___syscall195 (stat64)");
|
||||
debug!("emscripten::___syscall195 (stat64) {}", which);
|
||||
let pathname: u32 = varargs.get(instance);
|
||||
let buf: u32 = varargs.get(instance);
|
||||
|
||||
@ -733,11 +831,11 @@ pub extern "C" fn ___syscall195(
|
||||
|
||||
// fstat64
|
||||
pub extern "C" fn ___syscall197(
|
||||
_which: c_int,
|
||||
which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> c_int {
|
||||
debug!("emscripten::___syscall197 (fstat64)");
|
||||
debug!("emscripten::___syscall197 (fstat64) {}", which);
|
||||
let fd: c_int = varargs.get(instance);
|
||||
let buf: u32 = varargs.get(instance);
|
||||
|
||||
@ -783,11 +881,11 @@ pub extern "C" fn ___syscall202() -> gid_t {
|
||||
|
||||
// chown
|
||||
pub extern "C" fn ___syscall212(
|
||||
_which: c_int,
|
||||
which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> c_int {
|
||||
debug!("emscripten::___syscall212 (chown)");
|
||||
debug!("emscripten::___syscall212 (chown) {}", which);
|
||||
|
||||
let pathname: u32 = varargs.get(instance);
|
||||
let owner: u32 = varargs.get(instance);
|
||||
@ -800,11 +898,11 @@ pub extern "C" fn ___syscall212(
|
||||
|
||||
// fcntl64
|
||||
pub extern "C" fn ___syscall221(
|
||||
_which: c_int,
|
||||
which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> c_int {
|
||||
debug!("emscripten::___syscall221 (fcntl64)");
|
||||
debug!("emscripten::___syscall221 (fcntl64) {}", which);
|
||||
// fcntl64
|
||||
let _fd: i32 = varargs.get(instance);
|
||||
let cmd: u32 = varargs.get(instance);
|
||||
@ -814,13 +912,51 @@ pub extern "C" fn ___syscall221(
|
||||
}
|
||||
}
|
||||
|
||||
// prlimit64
|
||||
pub extern "C" fn ___syscall340(
|
||||
/// dup3
|
||||
pub extern "C" fn ___syscall330(
|
||||
_which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> pid_t {
|
||||
// Implementation based on description at https://linux.die.net/man/2/dup3
|
||||
debug!("emscripten::___syscall330 (dup3)");
|
||||
let oldfd: c_int = varargs.get(instance);
|
||||
let newfd: c_int = varargs.get(instance);
|
||||
let flags: c_int = varargs.get(instance);
|
||||
|
||||
if oldfd == newfd {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
let res = unsafe { dup2(oldfd, newfd) };
|
||||
|
||||
// Set flags on newfd (https://www.gnu.org/software/libc/manual/html_node/Descriptor-Flags.html)
|
||||
let mut old_flags = unsafe { fcntl(newfd, F_GETFD, 0) };
|
||||
|
||||
if old_flags > 0 {
|
||||
old_flags |= flags;
|
||||
} else if old_flags == 0 {
|
||||
old_flags &= !flags;
|
||||
}
|
||||
|
||||
unsafe {
|
||||
fcntl(newfd, F_SETFD, old_flags);
|
||||
}
|
||||
|
||||
debug!(
|
||||
"=> oldfd: {}, newfd: {}, flags: {} = pid: {}",
|
||||
oldfd, newfd, flags, res
|
||||
);
|
||||
res
|
||||
}
|
||||
|
||||
// prlimit64
|
||||
pub extern "C" fn ___syscall340(
|
||||
which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> c_int {
|
||||
debug!("emscripten::___syscall340 (prlimit64)");
|
||||
debug!("emscripten::___syscall340 (prlimit64), {}", which);
|
||||
// NOTE: Doesn't really matter. Wasm modules cannot exceed WASM_PAGE_SIZE anyway.
|
||||
let _pid: i32 = varargs.get(instance);
|
||||
let _resource: i32 = varargs.get(instance);
|
||||
@ -840,52 +976,3 @@ pub extern "C" fn ___syscall340(
|
||||
|
||||
0
|
||||
}
|
||||
|
||||
// dup2
|
||||
pub extern "C" fn ___syscall63(
|
||||
_which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> c_int {
|
||||
debug!("emscripten::___syscall63 (dup2)");
|
||||
|
||||
let src: i32 = varargs.get(instance);
|
||||
let dst: i32 = varargs.get(instance);
|
||||
|
||||
unsafe { dup2(src, dst) }
|
||||
}
|
||||
|
||||
// select
|
||||
pub extern "C" fn ___syscall142(
|
||||
_which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> c_int {
|
||||
debug!("emscripten::___syscall142 (newselect)");
|
||||
|
||||
let nfds: i32 = varargs.get(instance);
|
||||
let readfds: u32 = varargs.get(instance);
|
||||
let writefds: u32 = varargs.get(instance);
|
||||
let exceptfds: u32 = varargs.get(instance);
|
||||
let _timeout: i32 = varargs.get(instance);
|
||||
|
||||
assert!(nfds <= 64, "`nfds` must be less than or equal to 64");
|
||||
assert!(exceptfds == 0, "`exceptfds` is not supporrted");
|
||||
|
||||
let readfds_ptr = instance.memory_offset_addr(0, readfds as _) as _;
|
||||
let writefds_ptr = instance.memory_offset_addr(0, writefds as _) as _;
|
||||
|
||||
unsafe { select(nfds, readfds_ptr, writefds_ptr, 0 as _, 0 as _) }
|
||||
}
|
||||
|
||||
// setpgid
|
||||
pub extern "C" fn ___syscall57(
|
||||
_which: c_int,
|
||||
mut varargs: VarArgs,
|
||||
instance: &mut Instance,
|
||||
) -> c_int {
|
||||
debug!("emscripten::___syscall57 (setpgid)");
|
||||
let pid: i32 = varargs.get(instance);
|
||||
let pgid: i32 = varargs.get(instance);
|
||||
unsafe { setpgid(pid, pgid) }
|
||||
}
|
||||
|
@ -58,6 +58,24 @@ pub extern "C" fn _clock_gettime(clk_id: c_int, tp: c_int, instance: &mut Instan
|
||||
0
|
||||
}
|
||||
|
||||
/// emscripten: ___clock_gettime
|
||||
pub extern "C" fn ___clock_gettime(clk_id: c_int, tp: c_int, instance: &mut Instance) -> c_int {
|
||||
debug!("emscripten::___clock_gettime {} {}", clk_id, tp);
|
||||
_clock_gettime(clk_id, tp, instance)
|
||||
}
|
||||
|
||||
/// emscripten: _clock
|
||||
pub extern "C" fn _clock() -> c_int {
|
||||
debug!("emscripten::_clock");
|
||||
0 // TODO: unimplemented
|
||||
}
|
||||
|
||||
/// emscripten: _difftime
|
||||
pub extern "C" fn _difftime(t0: u32, t1: u32) -> c_int {
|
||||
debug!("emscripten::_difftime");
|
||||
(t0 - t1) as _
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
struct guest_tm {
|
||||
pub tm_sec: c_int, // 0
|
||||
@ -111,7 +129,7 @@ pub extern "C" fn _asctime(time: u32, instance: &mut Instance) -> u32 {
|
||||
let time_str_ptr = fmt_time(time, instance);
|
||||
copy_cstr_into_wasm(instance, time_str_ptr)
|
||||
|
||||
// let c_str = instance.memory_offset_addr(0, time_str_offset as _) as *mut i8;
|
||||
// let c_str = instance.memory_offset_addr(0, res as _) as *mut i8;
|
||||
// use std::ffi::CStr;
|
||||
// debug!("#### cstr = {:?}", CStr::from_ptr(c_str));
|
||||
}
|
||||
@ -119,7 +137,7 @@ pub extern "C" fn _asctime(time: u32, instance: &mut Instance) -> u32 {
|
||||
|
||||
/// emscripten: _asctime_r
|
||||
pub extern "C" fn _asctime_r(time: u32, buf: u32, instance: &mut Instance) -> u32 {
|
||||
debug!("emscripten::_asctime_r {}", time);
|
||||
debug!("emscripten::_asctime_r {}, {}", time, buf);
|
||||
|
||||
unsafe {
|
||||
// NOTE: asctime_r is specced to behave in an undefined manner if the algorithm would attempt
|
||||
@ -129,7 +147,7 @@ pub extern "C" fn _asctime_r(time: u32, buf: u32, instance: &mut Instance) -> u3
|
||||
let time_str_ptr = fmt_time(time, instance);
|
||||
write_to_buf(time_str_ptr, buf, 26, instance)
|
||||
|
||||
// let c_str = instance.memory_offset_addr(0, time_str_offset as _) as *mut i8;
|
||||
// let c_str = instance.memory_offset_addr(0, res as _) as *mut i8;
|
||||
// use std::ffi::CStr;
|
||||
// debug!("#### cstr = {:?}", CStr::from_ptr(c_str));
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ pub unsafe fn write_to_buf(string: *const c_char, buf: u32, max: u32, instance:
|
||||
buf
|
||||
}
|
||||
|
||||
/// This function expects nullbyte to be appended.
|
||||
pub unsafe fn copy_cstr_into_wasm(instance: &mut Instance, cstr: *const c_char) -> u32 {
|
||||
let s = CStr::from_ptr(cstr).to_str().unwrap();
|
||||
let cstr_len = s.len();
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::webassembly::Instance;
|
||||
use std::env;
|
||||
|
||||
pub extern "C" fn get_env(name: &str, _instance: &mut Instance) -> Result<String, env::VarError> {
|
||||
debug!("host::get_env({:?})", name);
|
||||
env::var(name)
|
||||
}
|
||||
// pub extern "C" fn get_env(name: &str, _instance: &mut Instance) -> Result<String, env::VarError> {
|
||||
// debug!("host::get_env({:?})", name);
|
||||
// env::var(name)
|
||||
// }
|
||||
|
26
src/common/file_descriptor.rs
Normal file
26
src/common/file_descriptor.rs
Normal file
@ -0,0 +1,26 @@
|
||||
use std::ffi::CString;
|
||||
use std::io;
|
||||
use std::io::Error;
|
||||
use std::io::ErrorKind;
|
||||
use std::io::Read;
|
||||
|
||||
pub struct FileDescriptor(libc::c_int);
|
||||
|
||||
impl FileDescriptor {
|
||||
pub fn new(file_descriptor_number: libc::c_int) -> FileDescriptor {
|
||||
FileDescriptor(file_descriptor_number)
|
||||
}
|
||||
}
|
||||
|
||||
impl Read for FileDescriptor {
|
||||
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
|
||||
let file_descriptor: libc::c_int = self.0;
|
||||
let count =
|
||||
unsafe { libc::read(file_descriptor, buf.as_mut_ptr() as *mut libc::c_void, 1) };
|
||||
if count < 0 {
|
||||
Err(Error::new(ErrorKind::Other, "read error"))
|
||||
} else {
|
||||
Ok(count as usize)
|
||||
}
|
||||
}
|
||||
}
|
@ -1,3 +1,6 @@
|
||||
pub mod mmap;
|
||||
pub mod slice;
|
||||
|
||||
mod file_descriptor;
|
||||
#[cfg(test)]
|
||||
pub mod stdio;
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::common::file_descriptor::FileDescriptor;
|
||||
use libc;
|
||||
use std::fs::File;
|
||||
use std::io::BufReader;
|
||||
use std::io::Read;
|
||||
use std::os::unix::io::FromRawFd;
|
||||
|
||||
// A struct to hold the references to the base stdout and the captured one
|
||||
pub struct StdioCapturer {
|
||||
@ -17,7 +17,15 @@ pub struct StdioCapturer {
|
||||
impl StdioCapturer {
|
||||
fn pipe() -> (libc::c_int, libc::c_int) {
|
||||
let mut fds = [0; 2];
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
assert_eq!(unsafe { libc::pipe(fds.as_mut_ptr()) }, 0);
|
||||
#[cfg(target_os = "windows")]
|
||||
assert_eq!(
|
||||
unsafe { libc::pipe(fds.as_mut_ptr(), 1000, libc::O_TEXT) },
|
||||
0
|
||||
);
|
||||
|
||||
(fds[0], fds[1])
|
||||
}
|
||||
|
||||
@ -28,9 +36,6 @@ impl StdioCapturer {
|
||||
let (stdout_reader, stdout_writer) = Self::pipe();
|
||||
let (stderr_reader, stderr_writer) = Self::pipe();
|
||||
|
||||
// std::io::stdout().flush().unwrap();
|
||||
// std::io::stderr().flush().unwrap();
|
||||
|
||||
assert!(unsafe { libc::dup2(stdout_writer, libc::STDOUT_FILENO) } > -1);
|
||||
assert!(unsafe { libc::dup2(stderr_writer, libc::STDERR_FILENO) } > -1);
|
||||
|
||||
@ -48,28 +53,23 @@ impl StdioCapturer {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn end(self) -> (String, String) {
|
||||
pub fn end(self) -> Result<(String, String), std::io::Error> {
|
||||
// The Stdio passed into the Command took over (and closed) std{out, err}
|
||||
// so we should restore them as they were.
|
||||
|
||||
assert!(unsafe { libc::dup2(self.stdout_backup, libc::STDOUT_FILENO) } > -1);
|
||||
assert!(unsafe { libc::dup2(self.stderr_backup, libc::STDERR_FILENO) } > -1);
|
||||
|
||||
// assert_eq!(unsafe { libc::close(self.stdout_backup) }, 0);
|
||||
// assert_eq!(unsafe { libc::close(self.stderr_backup) }, 0);
|
||||
let fd = FileDescriptor::new(self.stdout_reader);
|
||||
let mut reader = BufReader::new(fd);
|
||||
let mut stdout_read = "".to_string();
|
||||
let _ = reader.read_to_string(&mut stdout_read)?;
|
||||
|
||||
let mut stdout_read = String::new();
|
||||
let mut stdout_file: File = unsafe { FromRawFd::from_raw_fd(self.stdout_reader) };
|
||||
stdout_file
|
||||
.read_to_string(&mut stdout_read)
|
||||
.expect("failed to read from stdout file");
|
||||
let fd = FileDescriptor::new(self.stderr_reader);
|
||||
let mut reader = BufReader::new(fd);
|
||||
let mut stderr_read = "".to_string();
|
||||
let _ = reader.read_to_string(&mut stderr_read)?;
|
||||
|
||||
let mut stderr_read = String::new();
|
||||
let mut stderr_file: File = unsafe { FromRawFd::from_raw_fd(self.stderr_reader) };
|
||||
stderr_file
|
||||
.read_to_string(&mut stderr_read)
|
||||
.expect("failed to read from stdout file");
|
||||
|
||||
(stdout_read, stderr_read)
|
||||
Ok((stdout_read, stderr_read))
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ macro_rules! assert_emscripten_output {
|
||||
$args,
|
||||
)
|
||||
.unwrap();
|
||||
let output = capturer.end().0;
|
||||
let output = capturer.end().unwrap().0;
|
||||
let expected_output = include_str!($expected);
|
||||
assert_eq!(output, expected_output);
|
||||
}};
|
||||
|
9
src/emtests/env.rs
Normal file
9
src/emtests/env.rs
Normal file
@ -0,0 +1,9 @@
|
||||
#[test]
|
||||
fn test_env() {
|
||||
assert_emscripten_output!(
|
||||
"../../emtests/env.wasm",
|
||||
"env",
|
||||
vec![],
|
||||
"../../emtests/env.output"
|
||||
);
|
||||
}
|
@ -4,5 +4,6 @@
|
||||
// The _common module is not autogenerated, as it provides common macros for the emtests
|
||||
#[macro_use]
|
||||
mod _common;
|
||||
mod env;
|
||||
mod printf;
|
||||
mod puts;
|
||||
|
0
src/emtests/syscalls.rs
Normal file
0
src/emtests/syscalls.rs
Normal file
@ -15,7 +15,9 @@ use cranelift_wasm::{FuncIndex, GlobalInit};
|
||||
use indicatif::{ProgressBar, ProgressStyle};
|
||||
use rayon::prelude::*;
|
||||
|
||||
use libc::c_int;
|
||||
use region;
|
||||
use std::cell::UnsafeCell;
|
||||
use std::iter::FromIterator;
|
||||
use std::iter::Iterator;
|
||||
use std::mem::size_of;
|
||||
@ -72,6 +74,83 @@ pub struct EmscriptenData {
|
||||
pub memalign: extern "C" fn(u32, u32, &mut Instance) -> u32,
|
||||
pub memset: extern "C" fn(u32, i32, u32, &mut Instance) -> u32,
|
||||
pub stack_alloc: extern "C" fn(u32, &Instance) -> u32,
|
||||
pub jumps: Vec<UnsafeCell<[c_int; 27]>>,
|
||||
}
|
||||
|
||||
impl EmscriptenData {
|
||||
pub fn new(module: &Module, instance: &Instance) -> Self {
|
||||
unsafe {
|
||||
debug!("emscripten::new");
|
||||
let malloc_export = module.info.exports.get("_malloc");
|
||||
let free_export = module.info.exports.get("_free");
|
||||
let memalign_export = module.info.exports.get("_memalign");
|
||||
let memset_export = module.info.exports.get("_memset");
|
||||
let stack_alloc_export = module.info.exports.get("stackAlloc");
|
||||
|
||||
let mut malloc_addr = 0 as *const u8;
|
||||
let mut free_addr = 0 as *const u8;
|
||||
let mut memalign_addr = 0 as *const u8;
|
||||
let mut memset_addr = 0 as *const u8;
|
||||
let mut stack_alloc_addr = 0 as _;
|
||||
|
||||
if let Some(Export::Function(malloc_index)) = malloc_export {
|
||||
malloc_addr = instance.get_function_pointer(*malloc_index);
|
||||
}
|
||||
|
||||
if let Some(Export::Function(free_index)) = free_export {
|
||||
free_addr = instance.get_function_pointer(*free_index);
|
||||
}
|
||||
|
||||
if let Some(Export::Function(memalign_index)) = memalign_export {
|
||||
memalign_addr = instance.get_function_pointer(*memalign_index);
|
||||
}
|
||||
|
||||
if let Some(Export::Function(memset_index)) = memset_export {
|
||||
memset_addr = instance.get_function_pointer(*memset_index);
|
||||
}
|
||||
|
||||
if let Some(Export::Function(stack_alloc_index)) = stack_alloc_export {
|
||||
stack_alloc_addr = instance.get_function_pointer(*stack_alloc_index);
|
||||
}
|
||||
|
||||
EmscriptenData {
|
||||
malloc: mem::transmute(malloc_addr),
|
||||
free: mem::transmute(free_addr),
|
||||
memalign: mem::transmute(memalign_addr),
|
||||
memset: mem::transmute(memset_addr),
|
||||
stack_alloc: mem::transmute(stack_alloc_addr),
|
||||
jumps: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Emscripten __ATINIT__
|
||||
pub fn atinit(&self, module: &Module, instance: &Instance) -> Result<(), String> {
|
||||
debug!("emscripten::atinit");
|
||||
if let Some(&Export::Function(environ_constructor_index)) =
|
||||
module.info.exports.get("___emscripten_environ_constructor")
|
||||
{
|
||||
debug!("emscripten::___emscripten_environ_constructor");
|
||||
let ___emscripten_environ_constructor: extern "C" fn(&Instance) =
|
||||
get_instance_function!(instance, environ_constructor_index);
|
||||
call_protected!(___emscripten_environ_constructor(&instance))
|
||||
.map_err(|err| format!("{}", err))?;
|
||||
};
|
||||
// TODO: We also need to handle TTY.init() and SOCKFS.root = FS.mount(SOCKFS, {}, null)
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Emscripten __ATEXIT__
|
||||
pub fn atexit(&self, _module: &Module, _instance: &Instance) -> Result<(), String> {
|
||||
debug!("emscripten::atexit");
|
||||
use libc::fflush;
|
||||
use std::ptr;
|
||||
// Flush all open streams
|
||||
unsafe {
|
||||
fflush(ptr::null_mut());
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl EmscriptenData {
|
||||
@ -195,6 +274,10 @@ pub struct Instance {
|
||||
// Region start memory location
|
||||
// code_base: *const (),
|
||||
pub emscripten_data: Option<EmscriptenData>,
|
||||
|
||||
// Workarounds to prevent use after free issue
|
||||
memories_pointer: Vec<BoundedSlice<u8>>,
|
||||
tables_pointer: Vec<BoundedSlice<usize>>,
|
||||
}
|
||||
|
||||
/// Contains pointers to data (heaps, globals, tables) needed
|
||||
@ -638,6 +721,8 @@ impl Instance {
|
||||
import_functions,
|
||||
start_func,
|
||||
emscripten_data: None,
|
||||
memories_pointer,
|
||||
tables_pointer,
|
||||
};
|
||||
|
||||
if options.abi == InstanceABI::Emscripten {
|
||||
|
@ -147,6 +147,10 @@ pub fn get_isa() -> Box<isa::TargetIsa> {
|
||||
let mut builder = settings::builder();
|
||||
builder.set("opt_level", "best").unwrap();
|
||||
|
||||
if cfg!(not(test)) {
|
||||
builder.set("enable_verifier", "false").unwrap();
|
||||
}
|
||||
|
||||
let flags = settings::Flags::new(builder);
|
||||
debug_assert_eq!(flags.opt_level(), settings::OptLevel::Best);
|
||||
flags
|
||||
|
Loading…
x
Reference in New Issue
Block a user